|
2 | 2 | // This file is subject to the terms and conditions defined in |
3 | 3 | // file 'LICENSE', which is part of this source code package. |
4 | 4 |
|
5 | | -use color_eyre::{Result, eyre::eyre}; |
6 | | -use man::prelude::*; |
| 5 | +use clap::CommandFactory; |
| 6 | +use color_eyre::{eyre::eyre, eyre::Context, Result}; |
7 | 7 | use std::env; |
8 | 8 | use std::fs::{self, File}; |
9 | 9 | use std::io::Write; |
10 | 10 | use std::path; |
11 | 11 |
|
| 12 | +include!("src/cli.rs"); |
| 13 | + |
12 | 14 | fn generate_man_page<P: AsRef<path::Path>>(outdir: P) -> Result<()> { |
13 | 15 | let outdir = outdir.as_ref(); |
14 | 16 | let man_path = outdir.join("github-workflows-update.1"); |
15 | | - let manpage = Manual::new("github-workflows-update") |
16 | | - .about("Check github workflows for actions that can be updated") |
17 | | - .author(Author::new("Leandro Lisboa Penz").email("[email protected]")) |
18 | | - .flag( |
19 | | - Flag::new() |
20 | | - .short("-n") |
21 | | - .long("--dry-run") |
22 | | - .help("Don't update the workflows, just print what would be done"), |
23 | | - ) |
24 | | - .option( |
25 | | - Opt::new("output-format") |
26 | | - .short("-f") |
27 | | - .long("--output-format") |
28 | | - .default_value("standard") |
29 | | - .help( |
30 | | - "Output format for the outdated action messages; \ |
31 | | - one of \"standard\" or \"github-warning\"", |
32 | | - ), |
33 | | - ) |
34 | | - .flag( |
35 | | - Flag::new() |
36 | | - .long("--error-on-outdated") |
37 | | - .help("Return error if any outdated actions are found"), |
38 | | - ) |
39 | | - .flag( |
40 | | - Flag::new() |
41 | | - .short("-h") |
42 | | - .long("--help") |
43 | | - .help("Prints help information"), |
44 | | - ) |
45 | | - .flag( |
46 | | - Flag::new() |
47 | | - .short("-V") |
48 | | - .long("--version") |
49 | | - .help("Prints version information"), |
50 | | - ) |
51 | | - .arg(Arg::new("COMMAND")) |
52 | | - .arg(Arg::new("[ ARGS ]")) |
53 | | - .description( |
54 | | - "github-workflows-update reads all github workflow and checks the latest |
55 | | -available versions of all github actions and workflow dispatches used, showing |
56 | | -which ones can be updated and optionally updating them automatically.", |
57 | | - ) |
| 17 | + let cmd = Cli::command(); |
| 18 | + let manual: man::Manual = clap2man::Manual::try_from(&cmd) |
| 19 | + .wrap_err("error converting clap command to manual")? |
| 20 | + .into(); |
| 21 | + let manpage = manual |
58 | 22 | .example( |
59 | | - Example::new() |
| 23 | + man::prelude::Example::new() |
60 | 24 | .text( |
61 | 25 | "Update all actions used in all github workflows \ |
62 | 26 | under the current repository", |
63 | 27 | ) |
64 | 28 | .command("github-workflows-update"), |
65 | 29 | ) |
66 | 30 | .example( |
67 | | - Example::new() |
| 31 | + man::prelude::Example::new() |
68 | 32 | .text("Show outdated actions without updating them") |
69 | 33 | .command("github-workflows-update -n"), |
70 | 34 | ) |
|
0 commit comments