Skip to content

Commit

Permalink
Better names for command/option help methods
Browse files Browse the repository at this point in the history
  • Loading branch information
disq committed Mar 28, 2018
1 parent 8501ba5 commit 72d5d8e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions core/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func (c *CommandMap) String(optsOverride ...opt.OptionType) (s string) {
return
}

// GetCommandHelps returns a text of accepted Commands with their options and arguments, list of accepted options, and a count of command alternates
func GetCommandHelps(filter string) (string, []opt.OptionType, int) {
// CommandHelps returns a text of accepted Commands with their options and arguments, list of accepted options, and a count of command alternates
func CommandHelps(filter string) (string, []opt.OptionType, int) {
list := make(map[string][]string)
overrides := map[op.Operation]string{
op.Abort: "exit [exit code]",
Expand Down Expand Up @@ -189,8 +189,8 @@ func GetCommandHelps(filter string) (string, []opt.OptionType, int) {
return ret, optsUsed, len(list)
}

// GetCommandList returns a list of accepted Commands
func GetCommandList() []string {
// CommandList returns a list of accepted Commands
func CommandList() []string {
l := make(map[string]struct{})
for _, c := range Commands {
if c.Operation.IsInternal() {
Expand Down
4 changes: 2 additions & 2 deletions core/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ func (j *Job) Run(wp *WorkerParams) error {
if j.opts.Has(opt.Help) {
fmt.Fprintf(os.Stderr, "%v\n\n", UsageLine())

cl, opts, cnt := GetCommandHelps(j.command)
cl, opts, cnt := CommandHelps(j.command)

if ol := opt.GetOptionHelps(opts); ol != "" {
if ol := opt.OptionHelps(opts); ol != "" {
fmt.Fprintf(os.Stderr, "\"%v\" command options:\n", j.command)
fmt.Fprintf(os.Stderr, ol)
fmt.Fprint(os.Stderr, "\n\n")
Expand Down
4 changes: 2 additions & 2 deletions opt/opt.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func (o OptionType) HelpMessage() string {
return ""
}

// GetOptionHelps returns a text of accepted command options with their help messages
func GetOptionHelps(opts []OptionType) string {
// OptionHelps returns a text of accepted command options with their help messages
func OptionHelps(opts []OptionType) string {

filterMap := make(map[OptionType]struct{})
for _, f := range opts {
Expand Down
2 changes: 1 addition & 1 deletion s5cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
fmt.Fprint(os.Stderr, "Options:\n")
flag.PrintDefaults()

cl := core.GetCommandList()
cl := core.CommandList()
fmt.Fprint(os.Stderr, "\nCommands:")
fmt.Fprintf(os.Stderr, "\n %v\n", strings.Join(cl, ", "))
fmt.Fprintf(os.Stderr, "\nTo get help on a specific command, run \"%v <command> -h\"\n", os.Args[0])
Expand Down

0 comments on commit 72d5d8e

Please sign in to comment.