Git Product home page Git Product logo

Comments (4)

nullmem avatar nullmem commented on May 31, 2024

+1 for this. The Digital Ocean CLI utility, doctl has completion built in where all you have to do is add source <(doctl completion bash) to your .bashrc

from vultr-cli.

ddymko avatar ddymko commented on May 31, 2024

With the release of vultr-cli 2.6.0 the addition of shell completions was added just not documented yet.

If you run vultr-cli completion you will get

vultr-cli completion

Generate the autocompletion script for vultr-cli for the specified shell.
See each sub-command's help for details on how to use the generated script.

Usage:
  vultr-cli completion [command]

Available Commands:
  bash        generate the autocompletion script for bash
  fish        generate the autocompletion script for fish
  powershell  generate the autocompletion script for powershell
  zsh         generate the autocompletion script for zsh

These autocompletions will get printed to stdout and will require you to set them up.

Some guides

Bash:

  $ source <(yourprogram completion bash)

  # To load completions for each session, execute once:
  # Linux:
  $ yourprogram completion bash > /etc/bash_completion.d/yourprogram
  # macOS:
  $ yourprogram completion bash > /usr/local/etc/bash_completion.d/yourprogram

Zsh:

  # If shell completion is not already enabled in your environment,
  # you will need to enable it.  You can execute the following once:

  $ echo "autoload -U compinit; compinit" >> ~/.zshrc

  # To load completions for each session, execute once:
  $ yourprogram completion zsh > "${fpath[1]}/_yourprogram"

  # You will need to start a new shell for this setup to take effect.

fish:

  $ yourprogram completion fish | source

  # To load completions for each session, execute once:
  $ yourprogram completion fish > ~/.config/fish/completions/yourprogram.fish

PowerShell:

  PS> yourprogram completion powershell | Out-String | Invoke-Expression

  # To load completions for every new session, run:
  PS> yourprogram completion powershell > yourprogram.ps1
  # and source this file from your PowerShell profile.

from vultr-cli.

kpcyrd avatar kpcyrd commented on May 31, 2024

yo quick info, we're having trouble generating the shell completions in the Arch Linux package build because we build in a clean environment and there's no api key configured:

[kpcyrd@build vultr-cli-2.6.0]$ ./vultr-cli completion bash
Please export your VULTR API key as an environment variable or add `api-key` to your config file, eg:
export VULTR_API_KEY='<api_key_from_vultr_account>'
[kpcyrd@build vultr-cli-2.6.0]$ 

We're working around this by exporting a dummy value, but tab completion also requires a dummy value to work if no api key is already configured:

[user@localhost ~]% vultr-cli <tab>
export VULTR_API_KEY='<api_key_from_vultr_account>'
Please export your VULTR API key as an environment variable or add `api-key` to your config file, eg:
[user@localhost ~]% export VULTR_API_KEY=x
[user@localhost ~]% 
[user@localhost ~]% 
[user@localhost ~]% vultr-cli <tab>
account         -- Retrieve information about your account
apps            -- Display all available applications
backups         -- Display backups
bare-metal      -- bare-metal is used to access bare metal server commands
block-storage   -- block storage commands
completion      -- generate the autocompletion script for the specified shell
dns             -- dns is used to access dns commands
firewall        -- firewall is used to access firewall commands
help            -- Help about any command
instance        -- commands to interact with instances on vultr
iso             -- iso is used to access iso commands
load-balancer   -- load balancer commands
network         -- network interacts with network actions
object-storage  -- object storage commands
os              -- os is used to access os commands
plans           -- get information about Vultr plans
regions         -- get regions
reserved-ip     -- reserved-ip lets you interact with reserved-ip
script          -- startup script commands
snapshot        -- snapshot commands
ssh-key         -- ssh-key commands
user            -- user commands
version         -- Display current version of Vultr-cli

from vultr-cli.

ddymko avatar ddymko commented on May 31, 2024

@kpcyrd

This is due to how the CLI is currently designed. One of the first things it checks when executing your command is to see if the API Token is set (doesn't validate it yet). What you are doing is the only way around the current design. Set a dummy value so that it passes initial checks.

We have a ongoing ticket that will fix this behavior and introduce new features (#155)

from vultr-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.