From c39f7e3fa676759167e395709609345473140f96 Mon Sep 17 00:00:00 2001 From: Bert Frees Date: Mon, 5 Nov 2018 10:55:22 +0100 Subject: [PATCH] Separate mandatory from non-mandatory flags --- cli/cli.go | 15 ++++++++------- cli/scripts.go | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index aefd136..d914c36 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -46,16 +46,17 @@ Admin commands: List of global options: {{.Name}} help -g Detailed help for a single command: {{.Name}} help COMMAND ` - //TODO: Check if required options to write/ignore [] COMMAND_HELP_TEMPLATE = ` -Usage: {{.Parent.Name}} [GLOBAL_OPTIONS] {{.Name}} [OPTIONS] {{ .Arity.Description}} +Usage: {{.Parent.Name}} [GLOBAL_OPTIONS] {{.Name}}{{if .MandatoryFlags}} REQUIRED_OPTIONS{{end}}{{if .MandatoryFlags}} [OPTIONS]{{end}} {{ .Arity.Description}} {{.Description}} -{{if .Flags}} -Options: -{{range .Flags }} {{flagAligner .FlagStringPrefix}} {{.ShortDesc}} -{{end}} -{{end}} + +{{if .MandatoryFlags}}Required options: +{{range .MandatoryFlags }} {{flagAligner .FlagStringPrefix}} {{.ShortDesc}} +{{end}}{{end}} +{{if .NonMandatoryFlags}}{{if .MandatoryFlags}}Other options{{end}}{{if not .MandatoryFlags}}Options{{end}}: +{{range .NonMandatoryFlags }} {{flagAligner .FlagStringPrefix}} {{.ShortDesc}} +{{end}}{{end}} ` diff --git a/cli/scripts.go b/cli/scripts.go index a92617f..02c78f4 100644 --- a/cli/scripts.go +++ b/cli/scripts.go @@ -192,6 +192,7 @@ func scriptToCommand(script pipeline.Script, cli *Cli, link *PipelineLink) (req } return nil }, jobRequest) + command.SetArity(0, "") for _, input := range script.Inputs { name := getFlagName(input.Name, "i-", command.Flags())