Move app func to main

This commit is contained in:
Andinus 2020-04-24 19:52:18 +05:30
parent a01ce7b968
commit 53d4a70ed2
Signed by: andinus
GPG Key ID: B67D55D482A799FD
6 changed files with 32 additions and 30 deletions

View File

@ -2,14 +2,45 @@ package main
import (
"log"
"os"
"tildegit.org/andinus/cetus/cache"
"tildegit.org/andinus/lynx"
)
var (
version string = "v0.6.7"
dump bool
random bool
notify bool
print bool
err error
body string
file string
reqInfo map[string]string
apodDate string
)
func main() {
initCetus()
// Early Check: If command was not passed then print usage and
// exit. Later command & service both are checked, this check
// is for version command. If not checked then running cetus
// without any args will fail because os.Args[1] will panic
// the program & produce runtime error.
if len(os.Args) == 1 {
printUsage()
os.Exit(0)
}
parseArgs()
}
func initCetus() {
unveil()
app()
}
func unveil() {

View File

@ -8,35 +8,6 @@ import (
"time"
)
var (
version string = "v0.6.7"
dump bool
random bool
notify bool
print bool
err error
body string
file string
reqInfo map[string]string
apodDate string
)
func app() {
// Early Check: If command was not passed then print usage and
// exit. Later command & service both are checked, this check
// is for version command. If not checked then running cetus
// without any args will fail because os.Args[1] will panic
// the program & produce runtime error.
if len(os.Args) == 1 {
printUsage()
os.Exit(0)
}
parseArgs()
}
// parseArgs will be parsing the arguments, it will verify if they are
// correct. Flag values are also set by parseArgs.
func parseArgs() {