Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arguments are not explained in action --help #6

Open
davidferlay opened this issue Nov 27, 2023 · 3 comments
Open

Arguments are not explained in action --help #6

davidferlay opened this issue Nov 27, 2023 · 3 comments

Comments

@davidferlay
Copy link
Contributor

Context

  • Consider action defined as such:
➜  cat platform/actions/compare-artifact/action.yaml 
action:
  title: Compare artifact
  description: Get expected artifact to compare current one and generate diff file
  arguments:
    - name: username
      title: Username
      description: The username to get comparison artifact with
    - name: password
      title: Username
      description: The password to get comparison artifact with
  options:
    - name: override
      title: Overriden comparison reference (branch or tag name)
  image: platform-actions-compare-artifact:latest
  build:
    context: ./
    args:
      USER_ID: {{.current_uid }}
      GROUP_ID: {{.current_gid}}
    tags:
      - platform-actions-compare-artifact:latest
      - platform-actions-compare-artifact:1.0.0
  command:
    - sh
    - /action/x.sh
    - "{{.username}}"
    - "{{.password}}"
    - "{{.override}}"

Observed

  • We can see that options are described in --help (see --override) but arguments are not -username, password)
✗ launchr platform:compare-artifact --help
Usage:
  plasmactl platform:compare-artifact username password [flags]

Flags:
  -h, --help                              help for platform:compare-artifact
      --overriden_comparison_ref string   Overriden comparison reference (branch or tag name)

Global Flags:
      --keyring-passphrase string   Passphrase for keyring encryption/decryption
  -q, --quiet                       disable stdOut
  -v, --verbose count               log verbosity level, use -vvv DEBUG, -vv WARN, -v INFO

Expected

  • Both options and arguments should be listed in --help of actions
@davidferlay davidferlay changed the title Arguements are not explained in action --help Arguments are not explained in action --help Nov 27, 2023
@iignatevich
Copy link
Collaborator

doesn't look doable

launchr is based on cobra commands and they don't support --help for arguments
spf13/cobra#571
maximum we can add right now is sorta validation function with more description

like

ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		var comps []string
		if len(args) == 0 {
			comps = cobra.AppendActiveHelp(comps, "You must choose a name for the repo you are adding")
		} else if len(args) == 1 {
			comps = cobra.AppendActiveHelp(comps, "You must specify the URL for the repo you are adding")
		} else {
			comps = cobra.AppendActiveHelp(comps, "This command does not take any more arguments")
		}
		return comps, cobra.ShellCompDirectiveNoFileComp
	},

@lexbritvin
Copy link
Collaborator

We may implement through custom templates. I had some plans for it. Come to me for details.

@davidferlay
Copy link
Contributor Author

Why not contribute it to cobra istead ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants