Skip to content

Commit 3eab6eb

Browse files
Merge pull request #286 from cmleinz/cli-refactor
Refactor CLI code
2 parents 32d38e4 + 24742c7 commit 3eab6eb

File tree

12 files changed

+206
-225
lines changed

12 files changed

+206
-225
lines changed

anise-cli/src/args.rs

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::path::PathBuf;
22

3-
use clap::{Parser, Subcommand};
3+
use clap::{Args, Parser, Subcommand};
44
use hifitime::Epoch;
55

66
#[derive(Parser, Debug)]
77
#[clap(name="ANISE", author="Rabotin and ANISE contributors", version, about, long_about = None)]
8-
pub struct Args {
8+
pub struct CliArgs {
99
#[clap(subcommand)]
1010
pub action: Actions,
1111
}
@@ -43,26 +43,32 @@ pub enum Actions {
4343
/// Truncate the segment of the provided ID of the input NAIF DAF file to the provided start and end epochs
4444
/// Limitation: this may not work correctly if there are several segments with the same ID.
4545
/// Only works with Chebyshev Type 2 data types (i.e. planetary ephemerides).
46-
TruncDAFById {
47-
/// Input DAF file, SPK or BPC
48-
input: PathBuf,
49-
/// Output DAF file path
50-
output: PathBuf,
51-
/// ID of the segment to truncate
52-
id: i32,
53-
/// New start epoch of the segment
54-
start: Option<Epoch>,
55-
/// New end epoch of the segment
56-
end: Option<Epoch>,
57-
},
46+
TruncDAFById(TruncateById),
5847
/// Remove the segment of the provided ID of the input NAIF DAF file.
5948
/// Limitation: this may not work correctly if there are several segments with the same ID.
60-
RmDAFById {
61-
/// Input DAF file, SPK or BPC
62-
input: PathBuf,
63-
/// Output DAF file path
64-
output: PathBuf,
65-
/// ID of the segment to truncate
66-
id: i32,
67-
},
49+
RmDAFById(RmById),
50+
}
51+
52+
#[derive(Debug, PartialEq, Eq, PartialOrd, Args)]
53+
pub(crate) struct RmById {
54+
/// Input DAF file, SPK or BPC
55+
pub input: PathBuf,
56+
/// Output DAF file path
57+
pub output: PathBuf,
58+
/// ID of the segment to truncate
59+
pub id: i32,
60+
}
61+
62+
#[derive(Debug, PartialEq, Eq, PartialOrd, Args)]
63+
pub(crate) struct TruncateById {
64+
/// Input DAF file, SPK or BPC
65+
pub input: PathBuf,
66+
/// Output DAF file path
67+
pub output: PathBuf,
68+
/// ID of the segment to truncate
69+
pub id: i32,
70+
/// New start epoch of the segment
71+
pub start: Option<Epoch>,
72+
/// New end epoch of the segment
73+
pub end: Option<Epoch>,
6874
}

0 commit comments

Comments
 (0)