-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,240 +1,177 @@ | ||
.\" Automatically generated by Pandoc 3.1.6 | ||
.\" Automatically generated by Pandoc 3.1.9 | ||
.\" | ||
.\" Define V font for inline verbatim, using C font in formats | ||
.\" that render this, and otherwise B font. | ||
.ie "\f[CB]x\f[]"x" \{\ | ||
. ftr V B | ||
. ftr VI BI | ||
. ftr VB B | ||
. ftr VBI BI | ||
.\} | ||
.el \{\ | ||
. ftr V CR | ||
. ftr VI CI | ||
. ftr VB CB | ||
. ftr VBI CBI | ||
.\} | ||
.TH "op" "1" "September 2023" "Version 0.6.4" "local command shortcuts" | ||
.hy | ||
.TH "op" "1" "March 2024" "Version 0.6.5" "local command shortcuts" | ||
.SH NAME | ||
.PP | ||
\f[B]op\f[R] - local command shortcuts | ||
.SH SYNOPSIS | ||
.PP | ||
\f[B]op\f[R] CODE [ARGS] | ||
.PD 0 | ||
.P | ||
.PD | ||
\f[B]op\f[R] OPTIONS | ||
.SH DESCRIPTION | ||
.PP | ||
\f[B]opcode\f[R] lets you define a simple configuration file in any | ||
directory. | ||
.PP | ||
This file includes command shortcuts (\f[I]opcodes\f[R]) that can be | ||
executed by running \f[B]op CODE\f[R]. | ||
.SH OPTIONS | ||
.SS ? | ||
.PP | ||
Show all codes and their usage comments (#?) | ||
.SS --list, -l | ||
.PP | ||
List command codes | ||
.SS --show, -s | ||
.PP | ||
Show the config file (op.conf) | ||
.SS --what, -w [CODE] | ||
.PP | ||
Show the command for a given code or all codes | ||
.SS --edit, -e | ||
.PP | ||
Open the config file for editing | ||
.SS --add, -a CODE COMMAND... | ||
.PP | ||
Append a command to the config file | ||
.SS --help, -h | ||
.PP | ||
Show help message | ||
.SS --version, -v | ||
.PP | ||
Show version number | ||
.SH OPCODE FILE | ||
.PP | ||
Running \f[B]op\f[R] will look for a file named \f[B]op.conf\f[R] or | ||
\f[B]opcode\f[R] in the working directory. | ||
.PP | ||
The syntax of this file is simple - each line should contain a code and | ||
the command to run: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
code: command to run | ||
\f[R] | ||
.fi | ||
.EE | ||
.PP | ||
For example: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
commit: git commit -am \[dq]quick commit\[dq] | ||
\f[R] | ||
.fi | ||
.EE | ||
.PP | ||
With this configuration, you can now simply run: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
$ op commit | ||
\f[R] | ||
.fi | ||
.EE | ||
.PP | ||
Any argument provided to the CLI will be forwarded to the command, so | ||
with this configuration: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
commit: git commit -am | ||
\f[R] | ||
.fi | ||
.EE | ||
.PP | ||
You can supply a commit message: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
$ op commit \[dq]my commit message\[dq] | ||
\f[R] | ||
.fi | ||
.EE | ||
.SS Positional Arguments | ||
.PP | ||
In some cases, you may want to use the command line arguments in | ||
different positions in your command. | ||
Given this configuration: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
deploy: git commit -am \[dq]$1\[dq] && git push | ||
\f[R] | ||
.fi | ||
.EE | ||
.PP | ||
You can now run: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
$ op deploy \[dq]version 1.1.1\[dq] | ||
\f[R] | ||
.fi | ||
.EE | ||
.PP | ||
and it will be translated to this command | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
git commit -am \[dq]version 1.1.1\[dq] && git push | ||
\f[R] | ||
.fi | ||
.EE | ||
.PP | ||
This is made possible due to the fact that any command that contains a | ||
\f[B]$\f[R] character, will not have the command line arguments | ||
(\f[B]$\[at]\f[R]) appended to it. | ||
.SS Usage Comments | ||
.PP | ||
You may add special usage comments in your \f[V]op.conf\f[R] file. | ||
You may add special usage comments in your \f[CR]op.conf\f[R] file. | ||
These will be displayed alongside their command code when running | ||
\f[V]op ?\f[R]. | ||
The usage comments must start with \f[V]#?\f[R] and be placed underneath | ||
their associated command. | ||
\f[CR]op ?\f[R]. | ||
The usage comments must start with \f[CR]#?\f[R] and be placed | ||
underneath their associated command. | ||
.PP | ||
For example, this configuration file: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
# op.conf | ||
deploy: git commit -am \[dq]$1\[dq] && git push | ||
#? perform git commit and push. | ||
#? usage: op deploy COMMIT_MESSAGE | ||
pull: git pull | ||
#? perform git pull | ||
\f[R] | ||
.fi | ||
.EE | ||
.PP | ||
will result in this output: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
$ op ? | ||
deploy | ||
perform git commit and push. | ||
usage: op deploy COMMIT_MESSAGE | ||
pull | ||
perform git pull | ||
\f[R] | ||
.fi | ||
.EE | ||
.SS Private Commands | ||
.PP | ||
Using the keyword \f[V]private\f[R] in a separate line anywhere in your | ||
\f[V]op.conf\f[R] file will hide all subsequent commands from | ||
\f[V]op ?\f[R] and \f[V]op --list\f[R]. | ||
Using the keyword \f[CR]private\f[R] in a separate line anywhere in your | ||
\f[CR]op.conf\f[R] file will hide all subsequent commands from | ||
\f[CR]op ?\f[R] and \f[CR]op --list\f[R]. | ||
The private commands can still be executed. | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
deploy: op clean && op build | ||
test: docker compose run test | ||
private | ||
clean: rm tmp/* | ||
build: docker build | ||
\f[R] | ||
.fi | ||
.EE | ||
.SS Multiline Commands | ||
.PP | ||
You may split your command to multiple lines by ending the line with a | ||
backslash, and indenting the subsequent lines by at least one space: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
up: docker-compose build && \[rs] | ||
docker-compose up web | ||
\f[R] | ||
.fi | ||
.EE | ||
.SH PARTIAL COMMAND MATCHING | ||
.PP | ||
When running a command, opcode will first try to find an exact match. | ||
If none is found, it will try to find a command that starts with the | ||
code you typed. | ||
.PP | ||
In other words, if you have this in your \f[V]op.conf\f[R] file: | ||
In other words, if you have this in your \f[CR]op.conf\f[R] file: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
server: echo \[dq]Running Server\[dq] && rackup | ||
\f[R] | ||
.fi | ||
.EE | ||
.PP | ||
You can run it with \f[B]op server\f[R], \f[B]op s\f[R] and anything in | ||
between. | ||
The first matched command will be executed. | ||
.SH BASH COMPLETION | ||
.PP | ||
Opcode comes with bash completion. | ||
If you install opcode using the setup script, bash completion will be | ||
installed automatically. | ||
.PP | ||
If you install opcode manually, and would like to enable bash | ||
completion, simply add this to your \f[V]\[ti]/.bashrc\f[R]: | ||
completion, simply add this to your \f[CR]\[ti]/.bashrc\f[R]: | ||
.IP | ||
.nf | ||
\f[C] | ||
.EX | ||
complete -C \[aq]op --completion\[aq] op | ||
\f[R] | ||
.fi | ||
.EE | ||
.SH SOURCE CODE | ||
.PP | ||
https://github.com/dannyben/opcode | ||
.SH ISSUE TRACKER | ||
.PP | ||
https://github.com/dannyben/opcode/issues | ||
.SH AUTHORS | ||
Danny Ben Shitrit <https://github.com/dannyben>. |