diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-09 21:13:35 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-09 21:13:35 +1000 |
| commit | b900c16c533969feb8c7cb86e0709f496237b577 (patch) | |
| tree | 154810b49c56f72c069f216211fba60f3e942be0 /src | |
| parent | feat: create parser (diff) | |
| download | caelestia-cli-b900c16c533969feb8c7cb86e0709f496237b577.tar.gz caelestia-cli-b900c16c533969feb8c7cb86e0709f496237b577.tar.bz2 caelestia-cli-b900c16c533969feb8c7cb86e0709f496237b577.zip | |
parser: add func to run with args
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.py | 3 | ||||
| -rw-r--r-- | src/parser.py | 13 | ||||
| -rw-r--r-- | src/subcommands/clipboard.py | 5 | ||||
| -rw-r--r-- | src/subcommands/emoji.py | 5 | ||||
| -rw-r--r-- | src/subcommands/pip.py | 5 | ||||
| -rw-r--r-- | src/subcommands/record.py | 5 | ||||
| -rw-r--r-- | src/subcommands/scheme.py | 5 | ||||
| -rw-r--r-- | src/subcommands/screenshot.py | 5 | ||||
| -rw-r--r-- | src/subcommands/shell.py | 5 | ||||
| -rw-r--r-- | src/subcommands/toggle.py | 5 | ||||
| -rw-r--r-- | src/subcommands/variant.py | 5 | ||||
| -rw-r--r-- | src/subcommands/wallpaper.py | 5 | ||||
| -rw-r--r-- | src/subcommands/wsaction.py | 5 |
13 files changed, 69 insertions, 2 deletions
diff --git a/src/main.py b/src/main.py index e206a79..a01222d 100644 --- a/src/main.py +++ b/src/main.py @@ -1,4 +1,5 @@ from parser import parse_args if __name__ == "__main__": - parse_args() + args = parse_args() + args.func(args) diff --git a/src/parser.py b/src/parser.py index 5629c63..724992b 100644 --- a/src/parser.py +++ b/src/parser.py @@ -1,6 +1,7 @@ import argparse from data import get_scheme_names, scheme_variants +from subcommands import clipboard, emoji, pip, record, scheme, screenshot, shell, toggle, variant, wallpaper, wsaction def parse_args() -> argparse.Namespace: @@ -13,13 +14,14 @@ def parse_args() -> argparse.Namespace: # Create parser for shell opts shell_parser = command_parser.add_parser("shell", help="start or message the shell") - # TODO: use set_defaults to set func and run + shell_parser.set_defaults(func=shell.run) shell_parser.add_argument("message", nargs="*", help="a message to send to the shell") shell_parser.add_argument("-s", "--show", action="store_true", help="print all shell IPC commands") shell_parser.add_argument("-l", "--log", action="store_true", help="print the shell log") # Create parser for toggle opts toggle_parser = command_parser.add_parser("toggle", help="toggle a special workspace") + toggle_parser.set_defaults(func=toggle.run) toggle_parser.add_argument( "workspace", choices=["communication", "music", "sysmon", "specialws", "todo"], help="the workspace to toggle" ) @@ -28,6 +30,7 @@ def parse_args() -> argparse.Namespace: ws_action_parser = command_parser.add_parser( "workspace-action", help="execute a Hyprland workspace dispatcher in the current group" ) + ws_action_parser.set_defaults(func=wsaction.run) ws_action_parser.add_argument( "-g", "--group", action="store_true", help="whether to execute the dispatcher on a group" ) @@ -38,6 +41,7 @@ def parse_args() -> argparse.Namespace: # Create parser for scheme opts scheme_parser = command_parser.add_parser("scheme", help="manage the colour scheme") + scheme_parser.set_defaults(func=scheme.run) scheme_parser.add_argument("-g", "--get", action="store_true", help="print the current scheme") scheme_parser.add_argument("-r", "--random", action="store_true", help="switch to a random scheme") scheme_parser.add_argument("-n", "--name", choices=get_scheme_names(), help="the name of the scheme to switch to") @@ -46,12 +50,14 @@ def parse_args() -> argparse.Namespace: # Create parser for variant opts variant_parser = command_parser.add_parser("variant", help="manage the dynamic scheme variant") + variant_parser.set_defaults(func=variant.run) variant_parser.add_argument("-g", "--get", action="store_true", help="print the current dynamic scheme variant") variant_parser.add_argument("-s", "--set", choices=scheme_variants, help="set the current dynamic scheme variant") variant_parser.add_argument("-r", "--random", action="store_true", help="switch to a random variant") # Create parser for screenshot opts screenshot_parser = command_parser.add_parser("screenshot", help="take a screenshot") + screenshot_parser.set_defaults(func=screenshot.run) screenshot_parser.add_argument("-r", "--region", help="take a screenshot of a region") screenshot_parser.add_argument( "-f", "--freeze", action="store_true", help="freeze the screen while selecting a region" @@ -59,18 +65,22 @@ def parse_args() -> argparse.Namespace: # Create parser for record opts record_parser = command_parser.add_parser("record", help="start a screen recording") + record_parser.set_defaults(func=record.run) record_parser.add_argument("-r", "--region", action="store_true", help="record a region") record_parser.add_argument("-s", "--sound", action="store_true", help="record audio") # Create parser for clipboard opts clipboard_parser = command_parser.add_parser("clipboard", help="open clipboard history") + clipboard_parser.set_defaults(func=clipboard.run) clipboard_parser.add_argument("-d", "--delete", action="store_true", help="delete from clipboard history") # Create parser for emoji-picker opts emoji_parser = command_parser.add_parser("emoji-picker", help="toggle the emoji picker") + emoji_parser.set_defaults(func=emoji.run) # Create parser for wallpaper opts wallpaper_parser = command_parser.add_parser("wallpaper", help="manage the wallpaper") + wallpaper_parser.set_defaults(func=wallpaper.run) wallpaper_parser.add_argument("-g", "--get", action="store_true", help="print the current wallpaper") wallpaper_parser.add_argument("-r", "--random", action="store_true", help="switch to a random wallpaper") wallpaper_parser.add_argument("-f", "--file", help="the path to the wallpaper to switch to") @@ -90,6 +100,7 @@ def parse_args() -> argparse.Namespace: # Create parser for pip opts pip_parser = command_parser.add_parser("pip", help="picture in picture utilities") + pip_parser.set_defaults(func=pip.run) pip_parser.add_argument("-d", "--daemon", action="store_true", help="start the daemon") return parser.parse_args() diff --git a/src/subcommands/clipboard.py b/src/subcommands/clipboard.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/clipboard.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass diff --git a/src/subcommands/emoji.py b/src/subcommands/emoji.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/emoji.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass diff --git a/src/subcommands/pip.py b/src/subcommands/pip.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/pip.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass diff --git a/src/subcommands/record.py b/src/subcommands/record.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/record.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass diff --git a/src/subcommands/scheme.py b/src/subcommands/scheme.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/scheme.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass diff --git a/src/subcommands/screenshot.py b/src/subcommands/screenshot.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/screenshot.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass diff --git a/src/subcommands/shell.py b/src/subcommands/shell.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/shell.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass diff --git a/src/subcommands/toggle.py b/src/subcommands/toggle.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/toggle.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass diff --git a/src/subcommands/variant.py b/src/subcommands/variant.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/variant.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass diff --git a/src/subcommands/wallpaper.py b/src/subcommands/wallpaper.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/wallpaper.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass diff --git a/src/subcommands/wsaction.py b/src/subcommands/wsaction.py new file mode 100644 index 0000000..a94f3d0 --- /dev/null +++ b/src/subcommands/wsaction.py @@ -0,0 +1,5 @@ +from argparse import Namespace + + +def run(args: Namespace) -> None: + pass |