Beta Release
This commit is contained in:
@@ -20,6 +20,7 @@ const (
|
||||
MODE_EDIT_HOLD
|
||||
MODE_LIST_QUESTS
|
||||
MODE_LIST_SHIPS
|
||||
MODE_OUTPUT_HOLD_VALUE
|
||||
)
|
||||
|
||||
type AppState struct {
|
||||
@@ -49,13 +50,14 @@ func NewApp() *AppState {
|
||||
func (a *AppState) initialize() error {
|
||||
flag.StringVar(&a.ConfDir, "d", ".ncpt", "The configuration directory to use")
|
||||
flag.BoolVar(&a.Verbose, "v", false, "Run in Verbose mode")
|
||||
validateQuest := flag.String("c", "", "Validate the given quest is _c_orrect")
|
||||
validateShip := flag.String("C", "", "Validate the given ship is _C_orrect")
|
||||
validateQuest := flag.String("c", "", "Validate that the given quest is _c_orrect")
|
||||
validateShip := flag.String("C", "", "Validate that the given ship is _C_orrect")
|
||||
editQuest := flag.String("e", "", "Edit the given quest")
|
||||
editShip := flag.String("E", "", "Edit the given ship")
|
||||
listQuestsMode := flag.Bool("l", false, "List all available Quests")
|
||||
listShipsMode := flag.Bool("L", false, "List all available Ships")
|
||||
listQuestsMode := flag.Bool("l", false, "List available Quests")
|
||||
listShipsMode := flag.Bool("L", false, "List available Ships")
|
||||
editHold := flag.String("H", "", "Edit the hold for the given ship")
|
||||
outputHoldValue := flag.String("h", "", "Output the given value from the given ship's hold")
|
||||
|
||||
flag.Parse()
|
||||
a.Parms = flag.Args()
|
||||
@@ -87,6 +89,9 @@ func (a *AppState) initialize() error {
|
||||
} else if *editHold != "" {
|
||||
a.Mode = MODE_EDIT_HOLD
|
||||
a.Ship = data.NewShip(a.ConfDir, *editHold)
|
||||
} else if *outputHoldValue != "" {
|
||||
a.Mode = MODE_OUTPUT_HOLD_VALUE
|
||||
a.Ship = data.NewShip(a.ConfDir, *outputHoldValue)
|
||||
} else {
|
||||
a.Mode = MODE_RUN
|
||||
}
|
||||
@@ -111,6 +116,8 @@ func (a *AppState) run() int {
|
||||
return a.listQuests(a.Parms)
|
||||
case MODE_LIST_SHIPS:
|
||||
return a.listShips(a.Parms)
|
||||
case MODE_OUTPUT_HOLD_VALUE:
|
||||
return a.outputHoldValue(a.Parms)
|
||||
|
||||
default:
|
||||
return a.runQuest(a.Parms)
|
||||
|
@@ -1 +0,0 @@
|
||||
package main
|
@@ -65,3 +65,25 @@ func (a *AppState) editHold(parms []string) int {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (a *AppState) outputHoldValue(parms []string) int {
|
||||
if a.Ship == nil {
|
||||
cli.PrintErr("Ship name must be provided.")
|
||||
return 1
|
||||
}
|
||||
if err := a.Ship.Load(); err != nil {
|
||||
cli.PrintErr(err.Error())
|
||||
return 1
|
||||
}
|
||||
if len(parms) == 0 {
|
||||
cli.PrintErr("Hold key must be provided.")
|
||||
return 1
|
||||
}
|
||||
v, ok := a.Ship.Hold[parms[0]]
|
||||
if !ok {
|
||||
cli.PrintErr(fmt.Sprintf("No value for '%s' found", parms[0]))
|
||||
return 1
|
||||
}
|
||||
fmt.Println(v)
|
||||
return 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user