refactor: hand clap's own structs to the commands
This commit is contained in:
@@ -10,6 +10,7 @@ use std::path::{Path, PathBuf};
|
||||
use anyhow::{Context, Result, anyhow, bail};
|
||||
|
||||
use self::store::{Leads, Repo, ignored, leads, resolve, symlink_metadata_opt, tracked};
|
||||
use crate::cli::link as cli;
|
||||
use crate::ctx::Ctx;
|
||||
use crate::fsops::suffixed;
|
||||
use crate::output::{line, note, warning};
|
||||
@@ -19,8 +20,9 @@ const BACKUP_SUFFIX: &str = ".ahab-bak";
|
||||
const RESTORING_SUFFIX: &str = ".ahab-restoring";
|
||||
|
||||
// move untracked paths out of the repo and symlink them back
|
||||
pub fn add(ctx: &Ctx, paths: &[PathBuf], force: bool, store: Option<&Path>) -> Result<()> {
|
||||
let repo = Repo::discover(ctx, store)?;
|
||||
pub fn add(ctx: &Ctx, args: &cli::Add) -> Result<()> {
|
||||
let (paths, force) = (args.paths.as_slice(), args.force);
|
||||
let repo = Repo::discover(ctx, args.store.root())?;
|
||||
let report = Report::new(&repo);
|
||||
|
||||
if let [path] = paths {
|
||||
@@ -42,8 +44,9 @@ pub fn add(ctx: &Ctx, paths: &[PathBuf], force: bool, store: Option<&Path>) -> R
|
||||
}
|
||||
|
||||
// move paths in the store back into the repo, the inverse of add
|
||||
pub fn restore(ctx: &Ctx, paths: &[PathBuf], all: bool, store: Option<&Path>) -> Result<()> {
|
||||
let repo = Repo::discover(ctx, store)?;
|
||||
pub fn restore(ctx: &Ctx, args: &cli::Restore) -> Result<()> {
|
||||
let (paths, all) = (args.paths.as_slice(), args.all);
|
||||
let repo = Repo::discover(ctx, args.store.root())?;
|
||||
let report = Report::new(&repo);
|
||||
|
||||
// clap requires one or the other and refuses both, so only the two real
|
||||
@@ -225,8 +228,8 @@ pub fn stored_summary(ctx: &Ctx, store: Option<&Path>) -> Result<(PathBuf, usize
|
||||
}
|
||||
|
||||
// list what the store holds for this repository, the inverse of check
|
||||
pub fn list(ctx: &Ctx, store: Option<&Path>) -> Result<()> {
|
||||
let repo = Repo::discover(ctx, store)?;
|
||||
pub fn list(ctx: &Ctx, args: &cli::List) -> Result<()> {
|
||||
let repo = Repo::discover(ctx, args.store.root())?;
|
||||
let stored = stored_paths(&repo, &repo.store)?;
|
||||
|
||||
line!("store: {}", repo.store.display());
|
||||
|
||||
Reference in New Issue
Block a user