Skip to content

Commit

Permalink
prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorrFG committed Nov 5, 2023
1 parent 4f9ae34 commit da19255
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dotree"
version = "0.4.0"
version = "0.5.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
112 changes: 102 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
![](./demo.gif)

[TOC]

This is dotree, a small little program that reads a config file like this (following
platform standard, under linux it will look at `~/.config/dotree.dt`):

Expand All @@ -8,16 +12,13 @@ menu root {
}
menu git {
s: "git status"
d: "git diff"
c: "git commit"
am: "amend" - "git commit --amend --no-edit"
aam: "all amend" - "git commit -a --amend --no-edit"
ca: "git commit -a"
b: "git switch $(git branch | fzf)"
w: cmd {
vars output_dir, branch
"add worktree" - !"git worktree add -b "$branch" "$output_dir""!
"add worktree" - "git worktree add -b $branch $output_dir"
}
}
Expand Down Expand Up @@ -48,6 +49,75 @@ An alternate form of strings are protected strings: `!"<content>"!`, in which ca
characters between the `!` and the `"`. The characters are not mirrored on the closing
delimiter. So `!ab"<content>"ab!` is valid, but ~`!ab"<content>"ba!`~ is not.

For an example of a real world config, [click here](./example.dt)

### Command Arguments

Commands can have arguments, which will be queried interactively, like this:

```
...
menu git {
...
w: cmd {
vars output_dir, branch
"add worktree" - "git worktree add -b $branch $output_dir"
}
}
...
```

The values are exposed via environment variables to the callee.
If you invoke dt with additional arguments, the additional arguments will be used as values
for the vars. For example: `dt gw fknorr/some-feature /tmp/worktree_dir`.

### Repeating Commands

You can configure dotree to continue after a command was executed, so that you can trigger
the command again with a single keypress. This is usefull for example, if you want to
change screen brightness when you don't have a keyboard with appropriate keys:

```
menu root {
m: brightnessctl
}
menu brightnessctl {
+: cmd {
set repeat
"brightnessctl set +10%"
}
-: cmd {
set repeat
"brightnessctl set -10%"
}
}
```

You can also add `ignore_result` as a config option, in which case dotree won't escape
when the command has a non-zero exit code, like this:

```
menu brightnessctl {
...
+: cmd {
set repeat, ignore_result
"brightnessctl set +10%"
}
...
```

### Naming Menus

You can also assign a different display name to a menu, like this:

```
menu "Worktree" git_worktree {
...
}
```

### Local mode

If you start dotree with -l, it will search for a dotree.dt file between the cwd and the file
Expand All @@ -56,14 +126,36 @@ working directory before executing commands, to the containing directory. This w
use dotree as a more interactive version of [just](https://github.com/casey/just). I aliased
`dt -l` to `dtl`

## Roadmap
### Default Shell

By default, dotree uses "bash -euo pipefail -c" as shell invocation on linux, or "cmd /c" on
windows. The shell string is always appended as last argument. You can change the default shell
by setting the environment variable `DT_DEFAULT_SHELL` or on a per file basis, by placing
a shell directive as first element in the config file like this:

The following features are planned:
```
shell sh -c
- A configurable default shell
- clean up grammar
menu root {
g: git
m: misc
}
...
```

It is also possible to change the shell for a command, by putting a shell directive into a
command like this:

```
menu root {
p: cmd {
shell python -c
"python hi" - !"print("hello from python")"!
}
}
```

## Installation

For now, you will have to either clone the repo, and run `cargo install --path <repo-path>`
or `cargo install --git https://github.com/knorrfg/dotree`.
Download the appropriate binary for your platform (windows is untested) from the release page,
or install via cargo: `cargo install --git https://github.com/knorrfg/dotree`.
Binary file added demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions example.dt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
menu root {
g: git
m: misc
r: rust
c: config
}

menu config {
b: "bash base" - "helix $DOTFILES/bash/base_config.bash"
l: "bash local" - "helix ~/.bashrc.local"
i: "i3" - "nvim ~/.config/i3/config"
d: "dotree" - "helix ~/.config/dotree.dt"
n: "nvim" - "nvim ~/.config/nvim/init.lua"
}

menu rust {
c: "check paged" - "cargo check --color always 2>&1 | less -r"
l: "count lines" - "fd -ers -X cloc"
i: "install package" - "cargo install --path ."
}

menu git {
am: "amend staged" - "git commit --amend --no-edit"
aam: "amend all" - "git commit -a --amend --no-edit"
b: "git switch $(git branch | fzf)"
w: git_worktree
}

menu git_worktree {
a: cmd {
vars output_dir, branch
!"git worktree add -b "$branch" "$output_dir""!
}
l: "list" - "git worktree list"
p: "prune" - "git worktree prune"
}

menu misc {
s: "systemctl suspend"
mh: cmd{
vars file
"md2html" - !"
echo converting $file
pandoc "$file" -c ~/Sync/share/pandoc.css --toc --standalone \
--embed-resources -so "${file%.md}.html"
"!
}
th: cmd {
vars file, expected_hash
"test md5 hash" - !"
if [[ `md5sum $file | awk '{print $1}'` == $expected_hash ]]; then
echo 'success'
else
echo 'fail'; exit 1
fi
"!
}
r: cmd {
vars pattern, replacement
"grep replace" - !"
for f in $(rg "$pattern" -l); do
sed "s/$pattern/$replacement/g" -i $f
done
"!
}
x: cmd {
vars file
"extract" - !"7z x "$file" "-o${file}.d""!
}
p: cmd {
vars pat
"ps -e | grep -i $pat"
}
}

18 changes: 18 additions & 0 deletions mk-release.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /usr/bin/env bash

set -euo pipefail

pkg_id="$(cargo pkgid)"
tag=${pkg_id##*#}

cargo test
cargo build --release --target=x86_64-unknown-linux-musl
cargo build --release --target=x86_64-pc-windows-gnu

gh release create "$tag"\
--draft \
--notes-file release_notes.md

gh release upload "$tag" target/x86_64-unknown-linux-musl/release/dt \# linux musl binary
gh release upload "$tag" target/x86_64-pc-windows-gnu/release/dt.exe \# windows binary

0 comments on commit da19255

Please sign in to comment.