craigerl / aprsd

Amateur radio APRS daemon which listens for messages and responds. By KM6LYW.
Apache License 2.0
134 stars 20 forks source link

Click #12

Closed hemna closed 3 years ago

hemna commented 3 years ago

This patch adds click support for parsing command line, as well as outputting bash shell completion scripts for your preferred shell.

(.venv) waboring@dl360-1:~/devel/aprsd:(git::click) $  aprsd --help
Usage: aprsd [OPTIONS] COMMAND [ARGS]...

  Shell completion for click-completion-command Available shell types:
  bash         Bourne again shell   fish         Friendly interactive shell
  powershell   Windows PowerShell   zsh          Z shell Default type: auto

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  install        Install the click-completion-command completion
  sample-config  This dumps the config to stdout.
  server         Start the aprsd server process.
  show           Show the click-completion-command completion code

(.venv) waboring@dl360-1:~/devel/aprsd:(git::click) $  aprsd server --help
Usage: aprsd server [OPTIONS]

  Start the aprsd server process.

Options:
  --loglevel [CRITICAL|ERROR|WARNING|INFO|DEBUG]
                                  The log level to use for aprsd.log
                                  [default: DEBUG]

  --quiet                         Don't log to stdout
  --help                          Show this message and exit.

# aprsd show dumps out what it will put in your ~/.bash_completion
# when you run arpsd install
(.venv) waboring@dl360-1:~/devel/aprsd:(git::click) $  aprsd show
_aprsd_completion() {
    local IFS=$'\t'
    COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
                   COMP_CWORD=$COMP_CWORD \
                   _APRSD_COMPLETE=complete-bash $1 ) )
    return 0
}

complete -F _aprsd_completion -o default aprsd