noobaa / noobaa-operator

Operator for NooBaa - object data service for hybrid and multi cloud environments :cloud: :wrench:
https://www.noobaa.io
Apache License 2.0
101 stars 100 forks source link

nb completion printings #1019

Open shirady opened 1 year ago

shirady commented 1 year ago

Environment info

CLI version: 5.13.0 noobaa-image: noobaa/noobaa-core:master-20220913 operator-image: noobaa/noobaa-operator:5.13.0

Actual behavior

  1. Prints the script "under the hood"
  2. I'm not sure it works

Expected behavior

  1. Prompt back (Shell convention for success) or success message + how to use.
  2. Ability to complete noobaa functions

Steps to reproduce

  1. Based on the instructions here - the steps of ‘Build images’ and ‘Deploy noobaa’.
  2. nb completion
  3. Use tab to complete the command, for example, nb acc + tab in order to complete nb account

More information - Screenshots / Logs / Other output

Screenshot 2023-01-16 at 10 04 10

guymguym commented 1 year ago

@shirady I think --help has the answer:

❯ noobaa completion --help
Load noobaa completion to bash:
(add to your ~/.bashrc and ~/.bash_profile to auto load)

. <(noobaa completion)

Options:
      --alias='': Custom alias name to generate the completion for

Usage:
  noobaa completion [flags] [options]

Use "noobaa options" for a list of global command-line options (applies to all commands).
shirady commented 1 year ago

@guymguym I don't understand what should I do to use it right... (but it's a different thing). Anyway, in the case where the user uses it wrong (just nb completion without any prior step), I think it should print him an error and not the script in the terminal.

guymguym commented 1 year ago

It prints the shell completion script to be sourced into your shell. This is the pattern used by many tools, for example kubectl. But what you could do, is make the "completion" subcommand have subcommands of its own like kubectl completion does, so that noobaa completion bash will be the command that prints the script to stdout, and the "bare" noobaa completion command will just show help.

guymguym commented 1 year ago

BTW is this description not helpful?

Load noobaa completion to bash:
(add to your ~/.bashrc and ~/.bash_profile to auto load)

. <(noobaa completion)
nimrod-becker commented 1 year ago

@shirady do you feel the last 2 comments are solving the problem?

shirady commented 1 year ago

@nimrod-becker, no...