Script build_bash_completion
[hide private]
[frames] | no frames]

Script build_bash_completion

Script to generate bash_completion script for Ganeti.

Classes [hide private]
  CompletionWriter
Command completion writer class.
Functions [hide private]
 
WritePreamble(sw, support_debug)
Writes the script preamble.
 
WriteCompReply(sw, args, cur="\"$cur\"")
 
WriteCompletion(sw, scriptname, funcname, support_debug, commands=None, opts=None, args=None)
Writes the completion code for one command.
 
GetFunctionName(name)
 
GetCommands(filename, module)
Returns the commands defined in a module.
 
HaskellOptToOptParse(opts, kind)
Converts a Haskell options to Python cli_options.
 
HaskellArgToCliArg(kind, min_cnt, max_cnt)
Converts a Haskell options to Python _Argument.
 
ParseHaskellOptsArgs(script, output)
Computes list of options/arguments from help-completion output.
 
WriteHaskellCompletion(sw, script, htools=True, debug=True)
Generates completion information for a Haskell program.
 
WriteHaskellCmdCompletion(sw, script, debug=True)
Generates completion information for a Haskell multi-command program.
 
main()
Variables [hide private]
  _OPT_NAME_RE = re.compile(r"^-[a-zA-Z0-9]|--[a-z][-a-z0-9]+$")
Regular expression describing desired format of option names.
  _ARG_MAP = {"choices": cli.ArgChoice, "command": cli.ArgComman...
serialised kind to arg type

Imports: os, re, itertools, optparse, StringIO, constants, cli, utils, build, pathutils, burnin, _autoconf


Function Details [hide private]

WritePreamble(sw, support_debug)

 

Writes the script preamble.

Helper functions should be written here.

WriteCompletion(sw, scriptname, funcname, support_debug, commands=None, opts=None, args=None)

 

Writes the completion code for one command.

Parameters:
  • sw (ShellWriter) - Script writer
  • scriptname (string) - Name of command line program
  • funcname (string) - Shell function name
  • commands (list) - List of all subcommands in this program

GetCommands(filename, module)

 

Returns the commands defined in a module.

Aliases are also added as commands.

HaskellOptToOptParse(opts, kind)

 

Converts a Haskell options to Python cli_options.

Parameters:
  • opts (string) - comma-separated string with short and long options
  • kind (string) - type generated by Common.hs/complToText; needs to be kept in sync

HaskellArgToCliArg(kind, min_cnt, max_cnt)

 

Converts a Haskell options to Python _Argument.

Parameters:
  • kind (string) - type generated by Common.hs/argComplToText; needs to be kept in sync

WriteHaskellCompletion(sw, script, htools=True, debug=True)

 

Generates completion information for a Haskell program.

This converts completion info from a Haskell program into 'fake' cli_opts and then builds completion for them.

WriteHaskellCmdCompletion(sw, script, debug=True)

 

Generates completion information for a Haskell multi-command program.

This gathers the list of commands from a Haskell program and computes the list of commands available, then builds the sub-command list of options/arguments for each command, using that for building a unified help output.


Variables Details [hide private]

_OPT_NAME_RE

Regular expression describing desired format of option names. Long names can contain lowercase characters, numbers and dashes only.

Value:
re.compile(r"^-[a-zA-Z0-9]|--[a-z][-a-z0-9]+$")

_ARG_MAP

serialised kind to arg type

Value:
{"choices": cli.ArgChoice, "command": cli.ArgCommand, "file": cli.ArgF\
ile, "host": cli.ArgHost, "jobid": cli.ArgJobId, "onegroup": cli.ArgGr\
oup, "oneinstance": cli.ArgInstance, "onenode": cli.ArgNode, "oneos": \
cli.ArgOs, "string": cli.ArgUnknown, "suggests": cli.ArgSuggest,}