bin_efo/commands/epoch/cli_epoch.rs
1//! # `epoch` CLI module
2//!
3//! This module defines the command-line interface for the `efo epoch`
4//! sub-command.
5//!
6//! ## Overview of commands
7//!
8//! * **`log`** - list epochs in a git-log style.
9//! * **`switch`** - switch to a specific epoch (by id, name or tag).
10//! * **`next`** - compute the next epoch from the current one.
11//! * **`reset`** - delete all future events after the current epoch.
12//! * **`diff`** - show differences between two epochs.
13//! * **`tag`** - add a tag to the current epoch.
14//! * **`fsck`** - perform basic filesystem level maintenance.
15
16#![warn(missing_docs, clippy::missing_docs_in_private_items)]
17
18use clap::{Args, Subcommand};
19use lib_efo::epoch::EpochIdentifier;
20
21/// Top-level sub-command for the `efo epoch` command.
22///
23/// Each variant represents a distinct epoch operation that can be
24/// invoked from the command line.
25#[derive(Subcommand, Debug)]
26pub enum EpochCmd {
27 /// List all epochs - a git-log style view
28 Log(Log),
29
30 /// Switch to an epoch (by numeric ID, name, or tag)
31 Switch(Switch),
32
33 /// Compute the next epoch from the current one
34 Next(Next),
35
36 /// Delete *all* future events after the current epoch
37 Reset(Reset),
38
39 /// Show the differences between two epochs
40 Diff(Diff),
41
42 /// Add a tag to the current epoch
43 Tag(Tag),
44
45 /// Basic filesystem level maintenance
46 Fsck(Fsck),
47
48 /// Edits the summary for the current epoch
49 Summary(Summary),
50}
51
52/// Displays a git-log style list of epochs.
53///
54/// # Arguments
55/// * `limit` - (Optional) Limit the number of entries shown.
56/// Default: `50`.
57#[derive(Args, Debug)]
58pub struct Log {
59 /// (Optional) Limit the number of entries shown.
60 #[arg(short, long, default_value = "50")]
61 pub limit: usize,
62}
63
64/// Switches to the specified epoch. The target can be an integer,
65/// a name, or a tag.
66///
67/// # Arguments
68/// * `target` - The epoch to switch to.
69/// * `force` - If set, drops all pending work and forces the switch.
70#[derive(Args, Debug)]
71pub struct Switch {
72 /// The epoch to switch to - can be an integer, a name, or a tag.
73 #[arg(required = true)]
74 pub target: EpochIdentifier,
75
76 /// Optional confirmation flag (if you ever want to force-switch)
77 #[arg(long, short, help = "Force-switch dropping all the pending work")]
78 pub force: bool,
79}
80
81/// Computes the next epoch from the current one.
82#[derive(Args, Debug)]
83pub struct Next;
84
85/// Deletes all future events after the current epoch.
86#[derive(Args, Debug)]
87pub struct Reset;
88
89/// Shows the differences between two epochs.
90///
91/// # Arguments
92/// * `start` - The starting point to compute the differences.
93/// * `end` - The end point to compute the differences; defaults to the
94/// current epoch if omitted.
95#[derive(Args, Debug)]
96pub struct Diff {
97 #[arg(required = true)]
98 /// The starting point to compute the differences
99 pub start: EpochIdentifier,
100
101 /// The end point to compute the differences, the current epoch by default
102 // TODO: Change this epochId by another better object
103 pub end: Option<EpochIdentifier>,
104}
105
106/// Adds a tag to the current epoch.
107///
108/// # Arguments
109/// * `tag` - The tag to tag the current epoch with.
110#[derive(Args, Debug)]
111pub struct Tag {
112 #[arg(required = true)]
113 #[allow(clippy::missing_docs_in_private_items)]
114 pub tag: String,
115}
116
117/// Performs basic filesystem level maintenance.
118#[derive(Debug, Args)]
119pub struct Fsck {}
120
121/// Edits the current's epoch summary.
122#[derive(Debug, Args)]
123pub struct Summary {
124 #[arg(required = true)]
125 #[allow(clippy::missing_docs_in_private_items)]
126 pub summary: String,
127}