Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument parsing: Switch from docopt to clap #108

Merged
merged 8 commits into from
Oct 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
rust: [1.53, stable]
rust: [1.54, stable]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -60,10 +60,34 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.53
toolchain: 1.54
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

docs:
name: build docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: '0.4.4'
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Ensure that docs can be built
run: cd docs && mdbook build
- name: Generate usage string
run: cargo run -- --help > docs/src/usage-actual.txt
- name: Ensure that usage string is up to date
run: diff docs/src/usage{,-actual}.txt
102 changes: 89 additions & 13 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[package]
authors = ["Danilo Bargen <mail@dbrgn.ch>"]
authors = [
"Danilo Bargen <mail@dbrgn.ch>",
"Niklas Mohrin <dev@niklasmohrin.de>",
]
description = "Fetch and show tldr help pages for many CLI commands. Full featured offline client with caching support."
homepage = "https://github.com/dbrgn/tealdeer/"
license = "MIT/Apache-2.0"
Expand All @@ -19,7 +22,7 @@ path = "src/main.rs"
ansi_term = "0.12.0"
app_dirs = { version = "2", package = "app_dirs2" }
atty = "0.2"
docopt = "1"
clap = { version = "3.0.0-beta.5", features = ["std", "derive", "suggestions" ], default-features = false }
env_logger = { version = "0.9", optional = true }
log = "0.4"
reqwest = { version = "0.11.3", features = ["blocking", "rustls-tls", "rustls-tls-native-roots"], default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion bash_tealdeer
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _tealdeer()
_init_completion || return

case $prev in
-h|--help|-v|--version|-l|--list|-u|--update|-c|--clear-cache|-p|--pager|-m|--markdown|--show-paths|--seed-config|-q|--quiet)
-h|--help|-v|--version|-l|--list|-u|--update|-c|--clear-cache|-p|--pager|-r|--raw|--show-paths|--seed-config|-q|--quiet)
return
;;
-f|--render)
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.53"
msrv = "1.54"
3 changes: 2 additions & 1 deletion docs/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Tealdeer is straightforward to use, through the binary named `tldr`.

You can view the available options using `tldr --help`:

<!-- Note: To update the file below, run `cargo run -- --help > docs/src/usage.txt`. -->
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
```
{{#include ../../src/usage.docopt}}
{{#include usage.txt}}
```
30 changes: 30 additions & 0 deletions docs/src/usage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
tealdeer 1.4.1

Danilo Bargen <mail@dbrgn.ch>, Niklas Mohrin <dev@niklasmohrin.de>

A fast TLDR client

USAGE:
tldr [OPTIONS] [COMMAND]...

ARGS:
<COMMAND>... The command to show (e.g. `tar` or `git log`)

OPTIONS:
-l, --list List all commands in the cache
-f, --render <FILE> Render a specific markdown file
-o, --os <OS> Override the operating system [linux, osx, sunos, windows]
-L, --language <LANGUAGE> Override the language
-u, --update Update the local cache
-c, --clear-cache Clear the local cache
-p, --pager Use a pager to page output
-r, --raw Display the raw markdown instead of rendering it
-q, --quiet Suppress informational messages
--show-paths Show file and directory paths used by tealdeer
--config-path Show config file path
--seed-config Create a basic config
--color <WHEN> Control whether to use color [always, auto, never]
-v, --version Print the version
-h, --help Print help information

To view the user documentation, please visit https://dbrgn.github.io/tealdeer/.
4 changes: 2 additions & 2 deletions fish_tealdeer
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ complete -c tldr -s h -l help -d 'Print the help message.' -f
complete -c tldr -s v -l version -d 'Show version information.' -f
complete -c tldr -s l -l list -d 'List all commands in the cache.' -f
complete -c tldr -s f -l render -d 'Render a specific markdown file.' -r
complete -c tldr -s o -l os -d 'Override the operating system.' -xa 'linux osx sunos windows other'
complete -c tldr -s o -l os -d 'Override the operating system.' -xa 'linux osx sunos windows'
complete -c tldr -s u -l update -d 'Update the local cache.' -f
complete -c tldr -s c -l clear-cache -d 'Clear the local cache.' -f
complete -c tldr -s p -l pager -d 'Use a pager to page output.' -f
complete -c tldr -s m -l markdown -d 'Display the raw markdown instead of rendering it.' -f
complete -c tldr -s r -l raw -d 'Display the raw markdown instead of rendering it.' -f
complete -c tldr -s q -l quiet -d 'Suppress informational messages.' -f
complete -c tldr -l show-paths -d 'Show file and directory paths used by tealdeer.' -f
complete -c tldr -l seed-config -d 'Create a basic config.' -f
Expand Down
1 change: 0 additions & 1 deletion src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ impl Cache {
OsType::OsX => Some("osx"),
OsType::SunOs => Some("sunos"),
OsType::Windows => Some("windows"),
OsType::Other => None,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Default for RawStyle {
italic: false,
}
}
} // impl RawStyle
}

impl From<RawStyle> for Style {
fn from(raw_style: RawStyle) -> Self {
Expand Down
Loading