Skip to content

Commit 9308043

Browse files
committed
feat: support self-updating, autocomplete and loosen schema required fields
1 parent cbc2654 commit 9308043

23 files changed

Lines changed: 2599 additions & 158 deletions

Cargo.lock

Lines changed: 1591 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "ferrisume-cli"
33
description = "A JSON resume CLI tool"
4-
version = "0.5.3"
4+
version = "0.5.4"
55
license = "MIT"
66
repository = "https://github.com/van-sprundel/ferrisume"
77
edition = "2021"
@@ -27,6 +27,9 @@ tempfile = "3.12.0"
2727
directories = "6.0.0"
2828
lazy_static = "1.4.0"
2929
comfy-table = "7.1.4"
30+
self_update = { version = "1.0.0-rc.6", features = ["archive-zip", "compression-zip-deflate", "checksums"] }
31+
clap_complete = "4"
32+
jsonschema = { version = "0.47.0", default-features = false }
3033

3134
[[bin]]
3235
name = "ferrisume"
@@ -36,3 +39,7 @@ path = "src/main.rs"
3639
[profile.dist]
3740
inherits = "release"
3841
lto = "thin"
42+
43+
[dev-dependencies]
44+
flate2 = "1.1.9"
45+
tar = "0.4.46"

README.md

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,54 @@ cargo binstall ferrisume-cli
2424
Usage: ferrisume [COMMAND]
2525
2626
Commands:
27-
init Initialize a resume.json file
28-
themes List all available themes
29-
version Display version information
30-
theme Theme management commands
31-
watch Edit your resume in a live view
32-
export Export locally to .html or .pdf
33-
help Print this message or the help of the given subcommand(s)
27+
init Initialize a resume.json file
28+
themes List all available themes
29+
version Display version information
30+
update Update ferrisume to the latest release
31+
validate Validate a resume file against the JSON Resume schema
32+
completions Generate shell completions
33+
theme Theme management commands
34+
watch Edit your resume in a live view
35+
export Export locally to .html or .pdf
36+
help Print this message or the help of the given subcommand(s)
3437
3538
Options:
3639
-h, --help Print help
3740
-V, --version Print version
3841
```
3942

43+
## Self-updating
44+
45+
Ferrisume can update itself to the latest GitHub release:
46+
47+
```sh
48+
ferrisume update # download and install the latest version
49+
ferrisume update --check # only check whether a newer version exists
50+
```
51+
52+
Other commands print a hint when a newer version is available. The check runs
53+
at most once a day and caches its result; set `FERRISUME_NO_UPDATE_CHECK=1` to
54+
disable it entirely.
55+
56+
## Validation
57+
58+
```sh
59+
ferrisume validate # validates resume.json
60+
ferrisume validate -i cv.json
61+
```
62+
63+
Checks the file against the official [JSON Resume schema](https://jsonresume.org/schema/)
64+
and reports every violation with its location. All fields are optional — a
65+
resume without a phone number (or without most things) is valid and renders fine.
66+
67+
## Shell completions
68+
69+
```sh
70+
ferrisume completions fish > ~/.config/fish/completions/ferrisume.fish
71+
ferrisume completions bash > ~/.local/share/bash-completion/completions/ferrisume
72+
ferrisume completions zsh > ~/.zfunc/_ferrisume
73+
```
74+
4075
## Theme Discovery
4176

4277
Ferrisume discovers themes from (in order):

dist-workspace.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-da
1515
pr-run-mode = "upload"
1616
# Path that installers should place binaries in
1717
install-path = "CARGO_HOME"
18+
# Use .tar.gz on unix so `ferrisume update` (self_update crate) can extract release archives
19+
unix-archive = ".tar.gz"
1820
# Whether to install an updater program
1921
install-updater = false
2022
# Publish to crates.io after release

src/args.rs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,51 @@
1-
use clap::{Arg, ArgMatches, Command};
1+
use clap::{Arg, ArgAction, ArgMatches, Command};
22

33
pub fn args() -> ArgMatches {
4+
command().get_matches()
5+
}
6+
7+
pub fn command() -> Command {
48
Command::new("ferrisume")
59
.version(env!("CARGO_PKG_VERSION"))
610
.author("Ramon van Sprundel <ramonvansprundel@gmail.com>")
711
.about("A resume generator CLI tool")
812
.subcommand(Command::new("init").about("Initialize a resume.json file"))
913
.subcommand(Command::new("themes").about("List all available themes"))
1014
.subcommand(Command::new("version").about("Display version information"))
15+
.subcommand(
16+
Command::new("update")
17+
.about("Update ferrisume to the latest release")
18+
.arg(
19+
Arg::new("check")
20+
.long("check")
21+
.help("Only check whether a newer version is available")
22+
.action(ArgAction::SetTrue),
23+
),
24+
)
25+
.subcommand(
26+
Command::new("validate")
27+
.about("Validate a resume file against the JSON Resume schema")
28+
.arg(
29+
Arg::new("input")
30+
.short('i')
31+
.long("input")
32+
.value_name("INPUT")
33+
.help("Specify input file")
34+
.num_args(1)
35+
.required(false)
36+
.default_value("resume.json"),
37+
),
38+
)
39+
.subcommand(
40+
Command::new("completions")
41+
.about("Generate shell completions")
42+
.arg(
43+
Arg::new("shell")
44+
.help("Shell to generate completions for")
45+
.required(true)
46+
.value_parser(clap::value_parser!(clap_complete::Shell)),
47+
),
48+
)
1149
.subcommand(
1250
Command::new("theme")
1351
.about("Theme management commands")
@@ -99,5 +137,4 @@ pub fn args() -> ArgMatches {
99137
.default_value("resume.pdf"),
100138
),
101139
)
102-
.get_matches()
103140
}

0 commit comments

Comments
 (0)