Skip to content

Commit 3102ccc

Browse files
committed
feat(init): create install-man-pages subcommand
This is primarily intended for package managers to generate and install man-pages, but it could also be used by individuals who installed from source.
1 parent 6203171 commit 3102ccc

File tree

3 files changed

+27
-1
lines changed
  • git-branchless-init/src
  • git-branchless-opts/src
  • git-branchless/src/commands

3 files changed

+27
-1
lines changed

git-branchless-init/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use lib::util::ExitCode;
2222
use path_slash::PathExt;
2323
use tracing::{instrument, warn};
2424

25-
use git_branchless_opts::{write_man_pages, InitArgs};
25+
use git_branchless_opts::{write_man_pages, InitArgs, InstallManPagesArgs};
2626
use lib::core::config::{get_default_branch_name, get_default_hooks_dir, get_hooks_dir};
2727
use lib::core::dag::Dag;
2828
use lib::core::effects::Effects;
@@ -684,6 +684,17 @@ pub fn command_main(ctx: CommandContext, args: InitArgs) -> eyre::Result<ExitCod
684684
}
685685
}
686686

687+
/// Install the man-pages for `git-branchless` to the provided path.
688+
#[instrument]
689+
pub fn command_install_man_pages(
690+
ctx: CommandContext,
691+
args: InstallManPagesArgs,
692+
) -> eyre::Result<ExitCode> {
693+
let InstallManPagesArgs { path } = args;
694+
write_man_pages(&path)?;
695+
Ok(ExitCode(0))
696+
}
697+
687698
#[cfg(test)]
688699
mod tests {
689700
use super::{update_between_lines, ALL_ALIASES, UPDATE_MARKER_END, UPDATE_MARKER_START};

git-branchless-opts/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ pub struct InitArgs {
265265
pub main_branch_name: Option<String>,
266266
}
267267

268+
/// Install git-branchless's man-pages to the given path.
269+
#[derive(Debug, Parser)]
270+
pub struct InstallManPagesArgs {
271+
/// The path to install to. An example path might be `/usr/share/man`. The
272+
/// provded path will be appended with `man1`, etc., as appropriate.
273+
pub path: PathBuf,
274+
}
275+
268276
/// Query the commit graph using the "revset" language and print matching
269277
/// commits.
270278
///
@@ -425,6 +433,9 @@ pub enum Command {
425433
/// Initialize the branchless workflow for this repository.
426434
Init(InitArgs),
427435

436+
/// Install git-branchless's man-pages to the given path.
437+
InstallManPages(InstallManPagesArgs),
438+
428439
/// Move a subtree of commits from one location to another.
429440
///
430441
/// By default, `git move` tries to move the entire current stack if you

git-branchless/src/commands/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ fn command_main(ctx: CommandContext, opts: Opts) -> eyre::Result<ExitCode> {
7070

7171
Command::Init(args) => git_branchless_init::command_main(ctx, args)?,
7272

73+
Command::InstallManPages(args) => {
74+
git_branchless_init::command_install_man_pages(ctx, args)?
75+
}
76+
7377
Command::Move {
7478
source,
7579
dest,

0 commit comments

Comments
 (0)