Add todo and error command

install-scripts
trivernis 2 years ago
parent 5c6ea5e9a4
commit 5f6ece5f42
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -32,6 +32,7 @@ module auto_partition {
}
def efi_create_fs_ssd [device: string] {
todo "Implement SSD partitioning"
}
def efi_create_fs_hdd [device: string] {
@ -56,6 +57,7 @@ module auto_partition {
export def bios [device: string] {
debug "Creating bios partitions"
bios_layout $device
todo "Implement BIOS filesystems"
}
def bios_layout [device: string] {
@ -80,6 +82,7 @@ def main [cfg] {
}
} else {
info "Creating partitions manually"
todo "Implement manual partitioning"
}
info "Partitions created!"

@ -36,6 +36,6 @@ def main [cfg] {
if $cfg.preset == "GrubEfi" {
install_grub_efi $cfg.location
} else {
error make {msg: "Not implemented"}
todo "Implement GrubLegacy"
}
}

@ -2,4 +2,5 @@ let RUN_IN_CHROOT = true;
# Applies all system changes of `install-desktop`
def main [cfg] {
echo "Executing up task `install-desktop` with config" $cfg
todo "Implement install desktops"
}

@ -2,4 +2,5 @@ let RUN_IN_CHROOT = true;
# Applies all system changes of `install-flatpak`
def main [cfg] {
echo "Executing up task `install-flatpak` with config" $cfg
todo Implement install flatpak
}

@ -0,0 +1,51 @@
use embed_nu::{
nu_protocol::{engine::Command, Signature, SyntaxShape},
CallExt,
};
#[derive(Clone)]
pub struct ErrorCommand;
impl Command for ErrorCommand {
fn name(&self) -> &str {
"todo"
}
fn signature(&self) -> embed_nu::nu_protocol::Signature {
Signature::new("error")
.rest("message", SyntaxShape::Any, "The error message")
.category(embed_nu::nu_protocol::Category::Custom("Tourmaline".into()))
}
fn usage(&self) -> &str {
"Throws an error"
}
fn run(
&self,
engine_state: &embed_nu::nu_protocol::engine::EngineState,
stack: &mut embed_nu::nu_protocol::engine::Stack,
call: &embed_nu::nu_protocol::ast::Call,
_input: embed_nu::PipelineData,
) -> Result<embed_nu::PipelineData, embed_nu::nu_protocol::ShellError> {
let args: Vec<String> = call.rest(engine_state, stack, 0)?;
if args.is_empty() {
Err(embed_nu::nu_protocol::ShellError::GenericError(
String::from("Error"),
String::from("Error"),
Some(call.span()),
None,
vec![],
))
} else {
Err(embed_nu::nu_protocol::ShellError::GenericError(
String::from("Error"),
args.join(" "),
Some(call.span()),
None,
vec![],
))
}
}
}

@ -1,10 +1,14 @@
mod debug;
mod error;
mod info;
mod run;
mod todo;
mod warn;
mod with_cwd;
pub use debug::*;
pub use error::*;
pub use info::*;
pub use run::*;
pub use todo::*;
pub use warn::*;
pub use with_cwd::*;

@ -0,0 +1,51 @@
use embed_nu::{
nu_protocol::{engine::Command, Signature, SyntaxShape},
CallExt,
};
#[derive(Clone)]
pub struct TodoCommand;
impl Command for TodoCommand {
fn name(&self) -> &str {
"todo"
}
fn signature(&self) -> embed_nu::nu_protocol::Signature {
Signature::new("todo")
.rest("todo", SyntaxShape::Any, "Hints on what is todo")
.category(embed_nu::nu_protocol::Category::Custom("Tourmaline".into()))
}
fn usage(&self) -> &str {
"Aborts the program as this is not implemented yet"
}
fn run(
&self,
engine_state: &embed_nu::nu_protocol::engine::EngineState,
stack: &mut embed_nu::nu_protocol::engine::Stack,
call: &embed_nu::nu_protocol::ast::Call,
_input: embed_nu::PipelineData,
) -> Result<embed_nu::PipelineData, embed_nu::nu_protocol::ShellError> {
let args: Vec<String> = call.rest(engine_state, stack, 0)?;
if args.is_empty() {
Err(embed_nu::nu_protocol::ShellError::GenericError(
String::from("TODO"),
String::from("This is a TODO"),
Some(call.span()),
Some(String::from("Implement this functionality")),
vec![],
))
} else {
Err(embed_nu::nu_protocol::ShellError::GenericError(
String::from("TODO"),
format!("This is a TODO: {}", args.join(" ")),
Some(call.span()),
Some(String::from("Implement this functionality")),
vec![],
))
}
}
}

@ -6,7 +6,9 @@ use std::fs;
use crate::{distro::OSConfig, error::ScriptError, utils::CFG_PATH};
use miette::{Context, IntoDiagnostic, Result};
use super::commands::{DebugCommand, InfoCommand, RunCommand, WarnCommand, WithCwdCommand};
use super::commands::{
DebugCommand, ErrorCommand, InfoCommand, RunCommand, TodoCommand, WarnCommand, WithCwdCommand,
};
#[derive(Clone)]
pub struct ExecBuilder {
@ -25,10 +27,12 @@ impl ExecBuilder {
let mut ctx = embed_nu::Context::builder()
.with_command_groups(CommandGroupConfig::default().all_groups(true))?
.add_command(RunCommand)?
.add_command(ErrorCommand)?
.add_command(WarnCommand)?
.add_command(InfoCommand)?
.add_command(DebugCommand)?
.add_command(WithCwdCommand)?
.add_command(TodoCommand)?
.add_env_var("PWD", std::env::var("PWD").unwrap_or(String::from("/")))
.add_env_var(
"PATH",

@ -42,6 +42,7 @@ pub async fn generate_script_files<P: AsRef<Path>>(output: P) -> Result<()> {
r#"# Applies all system changes of `{name}`
def main [cfg] {{
echo "Executing up task `{name}` with config" $cfg
todo "Implement me"
}}
"#
),
@ -56,6 +57,7 @@ def main [cfg] {{
r#"# Reverts all system changes of `{name}`
def main [cfg] {{
echo "Executing up task `{name}` with config" $cfg
todo "Implement me"
}}
"#
)

Loading…
Cancel
Save