Last active
December 30, 2018 13:59
-
-
Save djthorpe/b83833baa5c74d594ecbd08770ab3e6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
// Frameworks | |
gopi "github.com/djthorpe/gopi" | |
// Modules | |
_ "github.com/djthorpe/gopi/sys/logger" | |
) | |
func Main(app *gopi.AppInstance, done chan<- struct{}) error { | |
app.Logger.Info("Started main thread") | |
if name, exists := app.AppFlags.GetString("name"); exists { | |
fmt.Println("Hello,", name) | |
} else { | |
fmt.Println("Hello, World (use -name flag to specify name)") | |
} | |
if wait, _ := app.AppFlags.GetBool("wait"); wait { | |
fmt.Println("Press CTRL+C to exit") | |
app.WaitForSignal() | |
} | |
return nil | |
} | |
func main() { | |
// Create the configuration | |
config := gopi.NewAppConfig("sys/logger") | |
config.AppFlags.FlagString("name", "", "Your name") | |
config.AppFlags.FlagBool("wait",true, "Wait for CTRL+C interrupt to end") | |
// Run the command line tool | |
os.Exit(gopi.CommandLineTool(config, Main)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment