mirror of
https://github.com/caelestia-dots/cli.git
synced 2026-06-05 14:59:29 -05:00
parser: print help when no args
Also create utility script for testing
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Utility script for rebuilding and running caelestia
|
||||
|
||||
cd $(dirname $0) || exit
|
||||
|
||||
sudo rm -r dist /usr/bin/caelestia /usr/lib/python3.*/site-packages/caelestia* 2> /dev/null
|
||||
python -m build --wheel --no-isolation > /dev/null
|
||||
sudo python -m installer --destdir=/ dist/*.whl > /dev/null
|
||||
|
||||
/usr/bin/caelestia "$@"
|
||||
@@ -2,12 +2,12 @@ from caelestia.parser import parse_args
|
||||
|
||||
|
||||
def main() -> None:
|
||||
args = parse_args()
|
||||
parser, args = parse_args()
|
||||
if "cls" in args:
|
||||
args.cls(args).run()
|
||||
else:
|
||||
import sys
|
||||
print("No arguments given", file=sys.stderr)
|
||||
parser.print_help()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -16,7 +16,7 @@ from caelestia.subcommands import (
|
||||
)
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
def parse_args() -> (argparse.ArgumentParser, argparse.Namespace):
|
||||
parser = argparse.ArgumentParser(prog="caelestia", description="Main control script for the Caelestia dotfiles")
|
||||
|
||||
# Add subcommand parsers
|
||||
@@ -122,4 +122,4 @@ def parse_args() -> argparse.Namespace:
|
||||
pip_parser.set_defaults(cls=pip.Command)
|
||||
pip_parser.add_argument("-d", "--daemon", action="store_true", help="start the daemon")
|
||||
|
||||
return parser.parse_args()
|
||||
return parser, parser.parse_args()
|
||||
|
||||
Reference in New Issue
Block a user