https://github.com/robotpy/robotpy-cli
Provides the `robotpy` and `python -m robotpy` commands for launching RobotPy projects
https://github.com/robotpy/robotpy-cli
Last synced: 5 months ago
JSON representation
Provides the `robotpy` and `python -m robotpy` commands for launching RobotPy projects
- Host: GitHub
- URL: https://github.com/robotpy/robotpy-cli
- Owner: robotpy
- License: bsd-3-clause
- Created: 2024-01-04T05:51:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-06T11:11:44.000Z (over 2 years ago)
- Last Synced: 2025-04-07T05:33:09.918Z (about 1 year ago)
- Language: Python
- Size: 8.79 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
robotpy-cli
===========
New for 2024, this package is used to execute subcommands on a RobotPy project.
This does not actually implement any subcommands itself, but provides a mechanism
to execute those subcommands.
Usage
-----
On Windows:
py -m robotpy
On Linux/macOS:
python -m robotpy
See the RobotPy documentation for more information.
How RobotPy subcommands are implemented
---------------------------------------
When a user runs `robotpy` or `python -m robotpy`, they are presented with
several subcommands. Each of these subcommands is implemented as a class
that is registered using python's entry point mechanism in the "robotpy_cli.YEAR"
group. The registered class must meet the following requirements:
* The docstring of the class is used when the user does --help. The first
line is treated as the summary, and all other lines are displayed when
the subcommand specific help is queried.
If the subcommand is a group of commands:
* The class must have a `subcommands` attribute, which is a list of
(name, subcommand_class) tuples. The subcommand_class must meet the requirements
for a subcommand.
If it is a subcommand that is executed:
* The constructor must take a single argument, an argparse.ArgumentParser.
The object may register any arguments or subparsers that it needs.
* The `run` function is called when the subcommand is used by the user.
The arguments to this function are passed in by name, and the names can
be any of the options that the subcommand registered. There are two other
special argument names:
* `options` - if specified, this is the Namespace returned by parse_args
* `robot_class` - if specified, the user's robot.py will be loaded and
it will be inspected for their robot class, which will be passed in
as this option
* `load_robot_class` - if specified, this is a function that will return
the same object that `robot_class` would have returned. The robot class
will *not* be loaded until the function is called. You may not specify
`robot_class` and `load_robot_class`, and you should not call the function
more than once.
* `main_file` - if specified, the name of the user's robot.py file. This
is not guaranteed to exist unless robot_class is also an option.
* `project_path` - if specified, the name of the directory that contains
the user's robot.py file. This is not guaranteed to exist unless robot_class
is also an option.