Skip to main content

talon_cli/cli/
related_args.rs

1//! Arguments for `talon related`.
2
3use clap::{Args, ValueEnum};
4
5use crate::cli::SharedScopeArgs;
6
7/// Direction variant for clap derive.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
9pub enum CliDirection {
10    /// Outgoing wikilinks.
11    Outgoing,
12    /// Backlinks.
13    Backlinks,
14    /// Outgoing wikilinks and backlinks.
15    Both,
16}
17
18impl From<CliDirection> for talon_core::Direction {
19    fn from(dir: CliDirection) -> Self {
20        match dir {
21            CliDirection::Outgoing => Self::Outgoing,
22            CliDirection::Backlinks => Self::Backlinks,
23            CliDirection::Both => Self::Both,
24        }
25    }
26}
27
28/// Arguments for the `related` subcommand.
29#[derive(Debug, Clone, Args)]
30#[command(about = "Find related notes via wikilink traversal.")]
31pub struct RelatedArgs {
32    /// Path to the note in the vault.
33    pub path: String,
34
35    /// Traversal depth (default 1).
36    #[arg(long)]
37    pub depth: Option<u8>,
38
39    /// Traversal direction.
40    #[arg(long, value_enum, ignore_case = true)]
41    pub direction: Option<CliDirection>,
42
43    #[command(flatten)]
44    pub scope: SharedScopeArgs,
45}