mirror of
https://github.com/nix-community/nurl.git
synced 2024-09-11 10:10:39 +03:00
generate man page and completions
This commit is contained in:
parent
b3f6b0de79
commit
942b477b0f
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -28,6 +28,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
rustup toolchain install stable --profile minimal -t ${{ matrix.target }}
|
rustup toolchain install stable --profile minimal -t ${{ matrix.target }}
|
||||||
cargo +stable build --target ${{ matrix.target }}
|
cargo +stable build --target ${{ matrix.target }}
|
||||||
|
env:
|
||||||
|
GEN_ARTIFACTS: artifacts
|
||||||
|
|
||||||
clippy-rustfmt:
|
clippy-rustfmt:
|
||||||
name: clippy-rustfmt
|
name: clippy-rustfmt
|
||||||
|
29
.github/workflows/release.yml
vendored
29
.github/workflows/release.yml
vendored
@ -53,3 +53,32 @@ jobs:
|
|||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
file: target/${{ matrix.target }}/release/nurl${{ matrix.ext }}
|
file: target/${{ matrix.target }}/release/nurl${{ matrix.ext }}
|
||||||
asset_name: nurl-${{ matrix.target }}${{ matrix.ext }}
|
asset_name: nurl-${{ matrix.target }}${{ matrix.ext }}
|
||||||
|
|
||||||
|
artifacts:
|
||||||
|
name: artifacts
|
||||||
|
needs: create_release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Cargo build
|
||||||
|
run: |
|
||||||
|
rustup toolchain install nightly --profile minimal
|
||||||
|
cargo +nightly build
|
||||||
|
env:
|
||||||
|
GEN_ARTIFACTS: artifacts
|
||||||
|
|
||||||
|
- name: Rename generated artifacts
|
||||||
|
run: |
|
||||||
|
mv artifacts/{_,}nurl.ps1
|
||||||
|
mv artifacts/{_nurl,nurl.zsh}
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
repo_token: ${{ github.token }}
|
||||||
|
tag: ${{ github.ref }}
|
||||||
|
file: artifacts/*
|
||||||
|
file_glob: true
|
||||||
|
27
Cargo.lock
generated
27
Cargo.lock
generated
@ -38,6 +38,15 @@ dependencies = [
|
|||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_complete"
|
||||||
|
version = "4.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.0.21"
|
version = "4.0.21"
|
||||||
@ -60,6 +69,16 @@ dependencies = [
|
|||||||
"os_str_bytes",
|
"os_str_bytes",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_mangen"
|
||||||
|
version = "0.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "904eb24d05ad587557e0f484ddce5c737c30cf81372badb16d13e41c4b8340b1"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
"roff",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "enum_dispatch"
|
name = "enum_dispatch"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@ -179,6 +198,8 @@ version = "0.1.1"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
"clap_complete",
|
||||||
|
"clap_mangen",
|
||||||
"enum_dispatch",
|
"enum_dispatch",
|
||||||
"indoc",
|
"indoc",
|
||||||
"serde",
|
"serde",
|
||||||
@ -246,6 +267,12 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "roff"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "0.36.6"
|
version = "0.36.6"
|
||||||
|
@ -23,6 +23,12 @@ url = "2.3.1"
|
|||||||
version = "4.0.32"
|
version = "4.0.32"
|
||||||
features = ["cargo", "derive", "unicode", "wrap_help"]
|
features = ["cargo", "derive", "unicode", "wrap_help"]
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
clap = { version = "4.0.32", features = ["derive"] }
|
||||||
|
clap_complete = "4.0.7"
|
||||||
|
clap_mangen = "0.2.6"
|
||||||
|
url = "2.3.1"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
29
build.rs
Normal file
29
build.rs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
use clap::CommandFactory;
|
||||||
|
use clap_complete::{generate_to, Shell};
|
||||||
|
use clap_mangen::Man;
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
env,
|
||||||
|
fs::{create_dir_all, File},
|
||||||
|
path::Path,
|
||||||
|
};
|
||||||
|
|
||||||
|
include!("src/cli.rs");
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-env-changed=GEN_ARTIFACTS");
|
||||||
|
|
||||||
|
if let Some(dir) = env::var_os("GEN_ARTIFACTS") {
|
||||||
|
let out = &Path::new(&dir);
|
||||||
|
create_dir_all(out).unwrap();
|
||||||
|
let cmd = &mut Opts::command();
|
||||||
|
|
||||||
|
Man::new(cmd.clone())
|
||||||
|
.render(&mut File::create(out.join("nurl.1")).unwrap())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
for shell in Shell::value_variants() {
|
||||||
|
generate_to(*shell, cmd, "nurl", out).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
flake.nix
11
flake.nix
@ -23,7 +23,7 @@
|
|||||||
packages = forEachSystem (system:
|
packages = forEachSystem (system:
|
||||||
let
|
let
|
||||||
inherit (nixpkgs.legacyPackages.${system})
|
inherit (nixpkgs.legacyPackages.${system})
|
||||||
gitMinimal makeWrapper mercurial nix rustPlatform;
|
gitMinimal installShellFiles makeWrapper mercurial nix rustPlatform;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
default = rustPlatform.buildRustPackage {
|
default = rustPlatform.buildRustPackage {
|
||||||
@ -34,13 +34,20 @@
|
|||||||
|
|
||||||
cargoLock.lockFile = self + "/Cargo.lock";
|
cargoLock.lockFile = self + "/Cargo.lock";
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [
|
||||||
|
installShellFiles
|
||||||
|
makeWrapper
|
||||||
|
];
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
wrapProgram $out/bin/nurl \
|
wrapProgram $out/bin/nurl \
|
||||||
--prefix PATH : ${makeBinPath [ gitMinimal mercurial nix ]}
|
--prefix PATH : ${makeBinPath [ gitMinimal mercurial nix ]}
|
||||||
|
installManPage artifacts/nurl.1
|
||||||
|
installShellCompletion artifacts/nurl.{bash,fish} --zsh artifacts/_nurl
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
GEN_ARTIFACTS = "artifacts";
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
inherit (package) description;
|
inherit (package) description;
|
||||||
license = licenses.mpl20;
|
license = licenses.mpl20;
|
||||||
|
Loading…
Reference in New Issue
Block a user