MCPcopy Index your code
hub / github.com/hugapi/hug / CLIRouter

Class CLIRouter

hug/routing.py:120–149  ·  view source on GitHub ↗

The CLIRouter provides a chainable router that can be used to route a CLI command to a Python function

Source from the content-addressed store, hash-verified

118
119
120class CLIRouter(Router):
121 """The CLIRouter provides a chainable router that can be used to route a CLI command to a Python function"""
122
123 __slots__ = ()
124
125 def __init__(self, name=None, version=None, doc=None, **kwargs):
126 super().__init__(**kwargs)
127 if name is not None:
128 self.route["name"] = name
129 if version:
130 self.route["version"] = version
131 if doc:
132 self.route["doc"] = doc
133
134 def name(self, name, **overrides):
135 """Sets the name for the CLI interface"""
136 return self.where(name=name, **overrides)
137
138 def version(self, version, **overrides):
139 """Sets the version for the CLI interface"""
140 return self.where(version=version, **overrides)
141
142 def doc(self, documentation, **overrides):
143 """Sets the documentation for the CLI interface"""
144 return self.where(doc=documentation, **overrides)
145
146 def __call__(self, api_function):
147 """Enables exposing a Hug compatible function as a Command Line Interface"""
148 hug.interface.CLI(self.route, api_function)
149 return api_function
150
151
152class InternalValidation(Router):

Callers 2

test_cliMethod · 0.90
TestCLIRouterClass · 0.90

Calls

no outgoing calls

Tested by 1

test_cliMethod · 0.72