Create ad-hoc commands to be dispatched in their own namespace.
Project description
ahd; Ad-Hoc Dispatcher
Create ad-hoc commands to be dispatched within their own namespace.
Quick-start
Installation
From Pypi
Run pip install ahd
or sudo pip3 install ahd
From source
- Clone this repo: (https://github.com/Descent098/ahd)
- Run
pip install .
orsudo pip3 install .
in the root directory
Usage
Usage:
ahd [-h] [-v] [-d]
ahd docs [-a] [-o]
ahd config [-e] [-i CONFIG_FILE_PATH]
ahd register <name> [<command>] [<paths>]
ahd <name> [<command>] [<paths>]
Options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-a, --api shows the local API docs
-o, --offline shows the local User docs instead of live ones
-e, --export exports the configuration file
-i CONFIG_FILE_PATH, --import CONFIG_FILE_PATH
imports the configuration file
Example
Here is a quick example of creating a command that runs sudo apt-get update && sudo apt-get upgrade
:
- Register the command as the name "update":
ahd register update "sudo apt-get update && sudo apt-get upgrade"
- Run the command using the name "update":
ahd update
This example was somewhat trivial but keep in mind this effectively means you can replace any short bash scripts you are using to do things like updating multiple git repos, executing a sequence of commands to sort your downloads folder etc.
Arguments
docs
The docs command is designed to bring up documentation as needed, you can run ahd docs
to open the documentation site in the default browser.
Options:
-a --api: Used to serve local API documentation (Not yet implemented)
-o --offline: Used to serve local user documentation (Not yet implemented)
config
This command is used for all configuration management. Due to the amount of preprocessing involved in keeping ahd cross platform the dotfile is obstructed from view by default. The config command is the main interface for managing configurations manually though I would recommend using the register command as opposed to this, or looking at the documentation for details about manual configuration.
Options:
-e --export: Export the current configuration file (it's a dotfile so make sure view hidden files is enabled)
-i --import: Import a configuration file; takes the path as an argument
Register
The register command allows you to register a name to be used later on. For example if I wanted to create a command that dispatched running git pull in several of my directories that is activated when I type ahd git-upt
then I can just run ahd register git-upt "git pull" "~/path/to/project, ~/path/to/project-2, ~/path/to/project-3
<name>
This is a placeholder value for the name of a command you have registered. Once the command is registered you can run it by using ahd <name>
, additionally you can override the default set commands or paths, details can be found at https://ahd.readthedocs.io/en/latest/usage#overriding.
Additional Documentation
Additional user and development/contribution documentation will be available at https://ahd.readthedocs.io/en/latest/.
Changelog
V 0.3.0; February 6th
Focus for this release was on building sustainable development pipelines (logging, testing etc.), and making the project more reliable in edge cases and error handling.
Features:
- Built out the testing suite to be run before release
- Built out the logging mechanism for debugging
- Introduced many error catches for various issues.
Bug Fixes:
- Added config command to bash autocomplete
V 0.2.1; February 2nd 2020
- Added support for . as current directory path
- Fixed issue with being unable to import configuration files
- Fixed issue with docs command when running --api
V 0.2.0; February 2nd 20202
Focus was on improving the overall useability of ahd. Note this version breaks backwards compatibility, but includes a migration guide in the docs (to be removed in V0.3.0).
Features:
- Bash Autocomplete implemented (ZSH and fish to come)
- Ability to export configuration
- Ability to import configuration
- Added a top level "docs" command to easy access documentation
- Added cross-platform wildcard support (see docs for usage)
- Added cross-platform home directory (see docs for details)
Bug fixes:
- Fixed issue where running "register" command without any flags would error out instead of printing help info
- Fixed issue with relative path tracking
Documentation improvements:
- Added issue templates for bug reports and feature requests
- Added pull request templates
- Added contribution guide
- Added migration information
- Added relevant documentation for all features released in V0.2.0
V 0.1.0; January 28th 2020
Initial release focused on creating the basic functionality for the ahd command.
Features:
- Ability to register a command
- Ability to specify command to run
- Ability to specify the location(s) to run the command in.
- Have commands store to a configuration file using configparser
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.