Provides a base class for defining subcommands of the Bokeh command line application.
Subcommand
Abstract base class for subcommands
Subclasses should implement an invoke(self, args) method that accepts a set of argparse processed arguments as input.
invoke(self, args)
Subclasses should also define the following class attributes:
name a name for this subcommand
name
help a help string for argparse to use for this subcommand
help
args the parameters to pass to parser.add_argument
args
parser.add_argument
The format of the args should be a sequence of tuples of the form:
('argname', dict( metavar='ARGNAME', nargs='+', ))
Example
A simple subcommand “foo” might look like this:
class Foo(Subcommand): name = "foo" help = "performs the Foo action" args = ( ('--yell', dict( action='store_true', help="Make it loud", )), ) def invoke(self, args): if args.yell: print("FOO!") else: print("foo")
Then executing bokeh foo --yell would print FOO! at the console.
bokeh foo --yell
FOO!
__init__
Initialize the subcommand with its parser
parser (Parser) – an Argparse Parser instance to configure with the args for this subcommand.
Parser
This method will automatically add all the arguments described in self.args. Subclasses can perform any additional customizations on self.parser.
self.args
self.parser
invoke
Takes over main program flow to perform the subcommand.
This method must be implemented by subclasses. subclassed overwritten methods return different types: bool: Build None: FileOutput (subclassed by HTML, SVG and JSON. PNG overwrites FileOutput.invoke method), Info, Init, Sampledata, Secret, Serve, Static
args (argparse.Namespace) – command line arguments for the subcommand to parse
NotImplementedError –