bokeh.command.subcommand#
Provides a base class for defining subcommands of the Bokeh command line application.
- class Subcommand(parser: ArgumentParser)[source]#
- Abstract base class for subcommands - Subclasses should implement an - invoke(self, args)method that accepts a set of argparse processed arguments as input.- Subclasses should also define the following class attributes: - namea name for this subcommand
- helpa help string for argparse to use for this subcommand
- argsthe parameters to pass to- parser.add_argument
 - The format of the - argsshould be a sequence of tuples of the form:- ('argname', Argument( metavar='ARGNAME', nargs='+', )) - Example - A simple subcommand “foo” might look like this: - class Foo(Subcommand): name = "foo" help = "performs the Foo action" args = ( ('--yell', Argument( action='store_true', help="Make it loud", )), ) def invoke(self, args): if args.yell: print("FOO!") else: print("foo") - Then executing - bokeh foo --yellwould print- FOO!at the console.- __init__(parser: ArgumentParser) None[source]#
- Initialize the subcommand with its parser - Parameters:
- parser (Parser) – an Argparse - Parserinstance to configure with the args for this subcommand.
 - This method will automatically add all the arguments described in - self.args. Subclasses can perform any additional customizations on- self.parser.
 - abstract invoke(args: Namespace) bool | None[source]#
- 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 - Parameters:
- args (argparse.Namespace) – command line arguments for the subcommand to parse 
- Raises: