Shell-independent task management CLI.
Project description
DOSH - shell-independent task manager
DOSH is a command-line application to run your tasks on any platform, on any shell. Define your tasks, aliases, environments in a dosh.lua file and run dosh. DOSH will work like a CLI app reading your config file.
INSTALLATION
Our GitHub Actions workflow builds app for these operating systems:
- Linux (aarch64, x86_64)
- MacOS (arm64)
- Windows (amd64)
For Linux and MacOS
sh <(curl https://raw.githubusercontent.com/gkmngrgn/dosh/main/install.sh) --install-dir $HOME/.local/bin
For Windows (PowerShell)
iwr https://raw.githubusercontent.com/gkmngrgn/dosh/main/install.ps1 -useb | iex
ANATOMY OF dosh.lua
local name = "there" -- you can use all features of Lua programming language.
local function hello(there) -- even you can define your custom functions.
there = there or name
local message = "Hello, " .. there .. "!"
cmd.run("osascript -e 'display notification \"" .. message .. "\" with title \"Hi!\"'")
end
cmd.add_task{ -- cmd comes from dosh.
name="hello", -- task name, or subcommand for your cli.
description="say hello", -- task description for the help output.
required_commands={"osascript"}, -- check if the programs exist before running the task.
required_platforms={"macos"}, -- check if the current operating system is available to run the task.
environments={"development", "staging"}, -- DOSH_ENV variable should be either development or staging to run this task.
command=hello -- run hello function with its parameters when the task ran.
}
When you run this command on MacOS, you will get a notification popup on the screen and see some logs in the console:
$ DOSH_ENV="development" dosh hello lua
DOSH => [RUN] osascript -e 'display notification "Hello, lua!" with title "Hi!"'
Take a look at the examples folder to find ready-in-use config files.
ENVIRONMENT VARIABLES
HELP OUTPUT
Help outputs consist of four parts: description, tasks, commands, and epilog. The tasks will be generated getting task names and descriptions from your config file. The commands are including pre-defined dosh tasks and common task parameters. All help outputs start with a description and ends with an epilog if you have.
If you want to edit the default description and add an epilog to the help output, you can modify these variables:
env.HELP_DESCRIPTIONenv.HELP_EPILOG
$ dosh help
dosh - shell-independent task manager # HELP_DESCRIPTION HERE
Tasks: # TASKS DEFINED BY THE USER
> hello say hello
Dosh commands:
> help print this output
> init initialize a new config in current working directory
> version print version of DOSH
-c, --config PATH specify config path (default: dosh.lua)
-d, --directory PATH change the working directory
-v|vv|vvv, --verbose increase the verbosity of messages:
1 - default, 2 - detailed, 3 - debug
Wikipedia says that an epilog is a piece of writing at the end of a work of # HELP_EPILOG HERE
literature, usually used to bring closure to the work.
OPERATING SYSTEM TYPE
All the following variables will return true or false depending on the operating system that you ran dosh:
env.IS_LINUXenv.IS_MACOSenv.IS_WINDOWS
SHELL TYPE
It's like OS type checking. It's useful if you use shell-specific package like ohmyzsh.
env.IS_BASHenv.IS_PWSHenv.IS_ZSH
DOSH-SPECIFIC ENVIRONMENTS
Consider you have some tasks that help you to test the project on your local and you want to restrict the task to prevent running it on the server by mistake. So the method cmd.add_task has an environments parameter and you can set your environment name for each target.
DOSH_ENV(define it on your~/.profilefile or CI/CD service)
Check out the file dosh_environments.lua for example usage.
COMMANDS
GENERAL PURPOSE
The main purpose of dosh to write one script that works on multiple operating systems and different shells. But it has to have a limit and it's nonsense to define functions for each cli command. So if you want to run a cli app (like exa, bat, helix, etc.), then you can use cmd.run for it.
Check out the file dosh_greet.lua for example usage.
FILE SYSTEM OPERATIONS
There are some ready-made functions both to keep the code readable and to make it work the same in all operating systems. You know Windows prefers backslash as a path separator but with dosh, use always / as in /foo/bar/baz, let dosh to find the path in a common way.
Check out the file dosh_config.lua for example usage.
PACKAGE MANAGERS
There are many package managers and I'm not sure if we need to implement all of them. But at least dosh supports these three of them mostly:
-
cmd.brew_install(for MacOS and Linux) -
packages: list of strings, required. -
cask: boolean, default isfalse. -
taps: list of strings, optional. -
cmd.apt_install(for Debian based Linux distros) -
packages: list of strings, required. -
cmd.winget_install(for Windows) -
packages: list of strings, required.
Check out the file dosh_config.lua for example usage.
FILE, FOLDER, COMMAND EXISTENCY
To check if file or folder exists, use cmd.exists. And if you want to check if a command exists, use cmd.exists_command.
LOGGING
You can manage the command outputs by defining the verbosity level. It's still possible to use print, but if you want to hide the command outputs completely or print them by the verbosity level, you have to use these logging functions:
cmd.debugcmd.infocmd.warningcmd.error
For more information about the verbosity parameter of dosh, type dosh help.
Check out the file dosh_greet.lua for example usage.
QUESTIONS
CAN I TRUST THIS PROJECT?
No. Don't trust any project. The source code is open, trust yourself and read the code.
BUT DO YOU USE THIS PROJECT YOURSELF?
Yes, of course. I use multiple operating systems with different shells, and I'm too tired to write my scripts in multiple languages. This is why I created this project.
BUT YOU COULD USE MAKEFILE, CMAKE, OR ANOTHER SIMILAR TOOL.
They are typically used to build and package software for distribution and are more geared towards building and managing software projects, while Dosh is more focused on running tasks from the command line. They serve different purposes and are not directly comparable. I keep these rules in mind:
-
If I need to add a paragraph to the
README.mdfile to explain how to configure the development environment and need to run some commands on my local, write a DOSH task namedsetupinstead, and then add just one sentence: "You can start development with a magic command: dosh setup." Or better yet, tell the contributors to typedosh helpto see all available tasks. -
If I don't want to create a project or repository for my personal tasks, I create
dosh.luain my home folder and write my tasks directly. For example, I have a task namedgit-syncthat pulls the latest changes from the remote server or warns me if there's a conflict in the repository. -
If I need a command alias but also need to run the command in Windows and Mac OS X, or in powershell and zsh, DOSH makes it simple.
WHY DOESN'T THIS PROJECT HAVE DOSH.LUA?
It doesn't make sense to make this project dependent on itself.
WHY DOESN'T DOSH HAVE ANY REMOVE COMMAND?
Because it's too dangerous! I don't use any remove command in my scripts indeed. If you really need a remove command, you can run it with cmd.run. But remember, contributors of this project don't guarantee anything.
CONTRIBUTION
Install these development dependencies manually:
$ uvx pre-commit run --all-files # for linting
$ uv run pytest # for testing
$ uv build # for building
$ uv pip install dist/dosh-*.whl # for installing
$ uv run dosh # testing the installation
$ uv run python -m dosh.cli # testing the cli without installing
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dosh_cli-0.2.4.tar.gz.
File metadata
- Download URL: dosh_cli-0.2.4.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd0c03fa2cb1a5e6a97253f43906bcb7f30270e7d81f29105385f72c7fd3b27c
|
|
| MD5 |
dbb4b95e7432b0ac0550b0ed240f8a08
|
|
| BLAKE2b-256 |
ccb42daeaa90f6f7e9fe456d66bfa1808d97f30ffc0de5dddbf82bb3772e4528
|
Provenance
The following attestation bundles were made for dosh_cli-0.2.4.tar.gz:
Publisher:
release.yml on gkmngrgn/dosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dosh_cli-0.2.4.tar.gz -
Subject digest:
cd0c03fa2cb1a5e6a97253f43906bcb7f30270e7d81f29105385f72c7fd3b27c - Sigstore transparency entry: 719130836
- Sigstore integration time:
-
Permalink:
gkmngrgn/dosh@9ae6df739cf2b89855cd351c4fac360066583bc4 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/gkmngrgn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9ae6df739cf2b89855cd351c4fac360066583bc4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dosh_cli-0.2.4-py3-none-any.whl.
File metadata
- Download URL: dosh_cli-0.2.4-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c07f8163b69ab162d185b3fa75638719a0edd382909764b1b7a77ac71f88eb5
|
|
| MD5 |
f5e2255a71d827a85603605671357fd8
|
|
| BLAKE2b-256 |
a1a692cb12e0a1e0c776134a048540fd2ae87538983f42bd35100af770c20873
|
Provenance
The following attestation bundles were made for dosh_cli-0.2.4-py3-none-any.whl:
Publisher:
release.yml on gkmngrgn/dosh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dosh_cli-0.2.4-py3-none-any.whl -
Subject digest:
9c07f8163b69ab162d185b3fa75638719a0edd382909764b1b7a77ac71f88eb5 - Sigstore transparency entry: 719130841
- Sigstore integration time:
-
Permalink:
gkmngrgn/dosh@9ae6df739cf2b89855cd351c4fac360066583bc4 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/gkmngrgn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9ae6df739cf2b89855cd351c4fac360066583bc4 -
Trigger Event:
push
-
Statement type: