Skip to content

Commit fdec3a2

Browse files
authored
docs: 🏗️ add pseudocode for subset() CLI (#137)
1 parent c7c5640 commit fdec3a2

2 files changed

Lines changed: 52 additions & 7 deletions

File tree

src/cli.rs

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
use clap::{Args, Subcommand};
22
use std::path::PathBuf;
3-
// Subcommand: parses command-line subcommands into the user-defined enum.
4-
// Args: We need to use clap::Args to parse the arguments for each command
5-
6-
pub mod build;
7-
pub mod check;
8-
pub mod create_request;
9-
pub mod subset;
3+
// use crate::core::{Rap, CheckedRap};
4+
// use crate::core::check::check_request;
5+
// use crate::core::metadata::{Package, read_package_metadata};
6+
// use crate::core::subset::{create_plan, SubsettedResource, subset_resources,
7+
// write_resources}; use std::path::PathBuf; // Or `Path`?
108

119
#[derive(Debug, Args)]
1210
pub struct BuildArgs {
@@ -71,3 +69,49 @@ pub enum Commands {
7169
/// package.
7270
Subset(SubsetArgs),
7371
}
72+
73+
/// Creates the requested subsets from the data package.
74+
///
75+
/// # Argument:
76+
///
77+
/// - `args`: This is the [`SubsetArgs`] struct that contains the CLI arguments
78+
/// for the `subset` command.
79+
#[allow(unused, clippy::needless_pass_by_value)]
80+
pub fn subset(args: SubsetArgs) {
81+
// TODO: Will we need to include some failure match here for reading issues?
82+
83+
// let request: Request = read_request(args.request)?;
84+
85+
// if args.show_plan {
86+
// // TODO: Not sure println is right approach.
87+
// println!("Plan for subsetting: {:?}", create_plan(args.request));
88+
// // End early.
89+
// return;
90+
// };
91+
92+
// TODO: Will we need to include some failure match here for reading issues?
93+
// let package_metadata: Package = read_package_metadata(args.source)?;
94+
95+
// let checked_rap: CheckedRap = check_request(Rap {
96+
// package: package_metadata,
97+
// request: request
98+
// });
99+
100+
// TODO: Not sure if Vec or Arc should be used.
101+
// TODO: Need to include failure matches here?
102+
// let subsetted_resources: Arc<[SubsettedResource]> =
103+
// subset_resources(checked_rap)?;
104+
105+
// TODO: Not sure if Path or PathBuf is better here.
106+
// let written_resources: Result<Path, Error> =
107+
// write_resources(subsetted_resources, args.output_dir);
108+
109+
// TODO: Need to include failure matches here?
110+
111+
// match written_resources {
112+
// Ok(paths) => println!("Created subset: {:?}", paths),
113+
// Err(e) => eprintln!("Failed to write ")
114+
// }
115+
116+
todo!("Planned")
117+
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// `lib.rs` is the file to indicate that this is a library crate. A library
22
// crate is a collection of Rust code that can be used by other Rust programs.
33

4+
pub mod cli;
45
pub mod core;

0 commit comments

Comments
 (0)