diff options
Diffstat (limited to 'src/cmds/cmd/workspace_init.rs')
| -rw-r--r-- | src/cmds/cmd/workspace_init.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/cmds/cmd/workspace_init.rs b/src/cmds/cmd/workspace_init.rs new file mode 100644 index 0000000..543c4db --- /dev/null +++ b/src/cmds/cmd/workspace_init.rs @@ -0,0 +1,51 @@ +use crate::{ + cmd_output, + cmds::{ + arg::empty::JVEmptyArgument, collect::empty::JVEmptyCollect, + converter::workspace_operation_error::JVWorkspaceOperationErrorConverter, + r#in::empty::JVEmptyInput, out::none::JVNoneOutput, + }, + systems::{ + cmd::{ + cmd_system::JVCommandContext, + errors::{CmdExecuteError, CmdPrepareError}, + }, + helpdoc::helpdoc_viewer, + }, +}; +use cmd_system_macros::exec; +use just_enough_vcs::system::workspace::func::create_workspace_here; +use std::any::TypeId; + +pub struct JVWorkspaceInitCommand; +type Cmd = JVWorkspaceInitCommand; +type Arg = JVEmptyArgument; +type In = JVEmptyInput; +type Collect = JVEmptyCollect; + +async fn help_str() -> String { + helpdoc_viewer::display("commands/workspace/init").await; + String::new() +} + +async fn prepare(_args: &Arg, _ctx: &JVCommandContext) -> Result<In, CmdPrepareError> { + Ok(JVEmptyInput) +} + +async fn collect(_args: &Arg, _ctx: &JVCommandContext) -> Result<Collect, CmdPrepareError> { + Ok(JVEmptyCollect) +} + +#[exec] +async fn exec( + _input: In, + _collect: Collect, +) -> Result<(Box<dyn std::any::Any + Send + 'static>, TypeId), CmdExecuteError> { + create_workspace_here() + .await + .map_err(JVWorkspaceOperationErrorConverter::to_exec_error)?; + + cmd_output!(JVNoneOutput => JVNoneOutput) +} + +crate::command_template!(); |
