feat: update highlevel
This commit is contained in:
@@ -82,9 +82,9 @@ pub enum CliCommands {
|
||||
#[command(name = "status")]
|
||||
#[command(about = "Fetch the status of registration with given manifest and scope.")]
|
||||
Status {
|
||||
/// The scope where fetch info.
|
||||
#[arg(short = 't', long = "target", value_name = "TARGET", required = true, value_enum, default_value_t = RegScope::User)]
|
||||
target: RegScope,
|
||||
/// The view where fetch info.
|
||||
#[arg(short = 't', long = "target", value_name = "TARGET", required = true, value_enum, default_value_t = RegView::User)]
|
||||
target: RegView,
|
||||
},
|
||||
#[command(name = "ext")]
|
||||
#[command(about = "File extension related operations according to given program manifest.")]
|
||||
|
||||
@@ -8,15 +8,18 @@ use thiserror::Error as TeError;
|
||||
/// Error occurs in this module.
|
||||
#[derive(Debug, TeError)]
|
||||
pub enum Error {
|
||||
/// Error when parsing manifest TOML file.
|
||||
/// Error when parsing Manifest TOML file.
|
||||
#[error("{0}")]
|
||||
ParseManifest(#[from] manifest::ParseManifestError),
|
||||
/// Error when parsing manifest into schema.
|
||||
/// Error when parsing Manifest into Schema.
|
||||
#[error("{0}")]
|
||||
ParseSchema(#[from] manifest::ParseSchemaError),
|
||||
/// Error when parsing schema into program.
|
||||
/// Error when parsing Schema into Program.
|
||||
#[error("{0}")]
|
||||
ParseProgram(#[from] wfassoc::highlevel::ParseProgramError),
|
||||
/// Error when operating Program.
|
||||
#[error("{0}")]
|
||||
Program(#[from] wfassoc::highlevel::ProgramError),
|
||||
}
|
||||
|
||||
/// Result type used in this module.
|
||||
@@ -34,16 +37,22 @@ fn stringified_exts_to_indices(program: &wfassoc::Program, exts: Vec<String>) ->
|
||||
|
||||
// region: Respective Runners
|
||||
|
||||
fn run_register(program: wfassoc::Program, scope: wfassoc::Scope) -> Result<()> {
|
||||
todo!()
|
||||
fn run_register(mut program: wfassoc::Program, scope: wfassoc::Scope) -> Result<()> {
|
||||
Ok(program.register(scope)?)
|
||||
}
|
||||
|
||||
fn run_unregister(program: wfassoc::Program, scope: wfassoc::Scope) -> Result<()> {
|
||||
todo!()
|
||||
fn run_unregister(mut program: wfassoc::Program, scope: wfassoc::Scope) -> Result<()> {
|
||||
Ok(program.unregister(scope)?)
|
||||
}
|
||||
|
||||
fn run_status(program: wfassoc::Program, scope: wfassoc::Scope) -> Result<()> {
|
||||
todo!()
|
||||
fn run_status(program: wfassoc::Program, view: wfassoc::View) -> Result<()> {
|
||||
if program.is_registered(view)? {
|
||||
println!("Application is installed.");
|
||||
} else {
|
||||
println!("Application is not installed.");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_ext_link(program: wfassoc::Program, scope: wfassoc::Scope, exts: Vec<String>) -> Result<()> {
|
||||
|
||||
@@ -167,17 +167,43 @@ pub struct Program {
|
||||
impl TryFrom<Schema> for Program {
|
||||
type Error = ParseProgramError;
|
||||
|
||||
fn try_from(value: Schema) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(value: Schema) -> Result<Self, Self::Error> {
|
||||
Self::new(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl Program {
|
||||
/// Try creating Program from Schema.
|
||||
pub fn new(schema: Schema) -> Result<Self, ParseProgramError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Program {
|
||||
/// Register this application.
|
||||
///
|
||||
/// If there is registration of this application,
|
||||
/// this function will return error.
|
||||
pub fn register(&mut self, scope: Scope) -> Result<(), ProgramError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Unregister this application.
|
||||
///
|
||||
/// If there is no registration of this application,
|
||||
/// this function will return error.
|
||||
pub fn unregister(&mut self, scope: Scope) -> Result<(), ProgramError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Check whether this application has been registered in given view.
|
||||
///
|
||||
/// Please note that this is a rough check and do not validate any data.
|
||||
pub fn is_registered(&self, view: View) -> Result<bool, ProgramError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region: Program Internals
|
||||
|
||||
Reference in New Issue
Block a user