Skip to content

Commit

Permalink
chore: ♻️ Remove unused --config parameter for now
Browse files Browse the repository at this point in the history
  • Loading branch information
ddanier committed Mar 10, 2024
1 parent 80786e2 commit 980d862
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 35 deletions.
53 changes: 27 additions & 26 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use nu_protocol::report_error;
use nu_protocol::{
ast::{Expr, Expression, PipelineElement},
engine::{Command, EngineState, Stack, StateWorkingSet},
ShellError, Spanned,
ShellError,
// Spanned,
};
use nu_utils::stdout_write_all_and_flush;
use crate::commands::Nur;
Expand Down Expand Up @@ -75,36 +76,36 @@ pub(crate) fn parse_commandline_args(
},
)) = pipeline.elements.first()
{
let config_file = call.get_flag_expr("config");
// let config_file = call.get_flag_expr("config");
let list_tasks = call.has_flag(engine_state, &mut stack, "list")?;
let quiet_execution = call.has_flag(engine_state, &mut stack, "quiet")?;
let attach_stdin = call.has_flag(engine_state, &mut stack, "stdin")?;
let show_help = call.has_flag(engine_state, &mut stack, "help")?;
#[cfg(feature = "debug")]
let debug_output = call.has_flag(engine_state, &mut stack, "debug")?;

fn extract_contents(
expression: Option<&Expression>,
) -> Result<Option<Spanned<String>>, ShellError> {
if let Some(expr) = expression {
let str = expr.as_string();
if let Some(str) = str {
Ok(Some(Spanned {
item: str,
span: expr.span,
}))
} else {
Err(ShellError::TypeMismatch {
err_message: "string".into(),
span: expr.span,
})
}
} else {
Ok(None)
}
}

let config_file = extract_contents(config_file)?;
// fn extract_contents(
// expression: Option<&Expression>,
// ) -> Result<Option<Spanned<String>>, ShellError> {
// if let Some(expr) = expression {
// let str = expr.as_string();
// if let Some(str) = str {
// Ok(Some(Spanned {
// item: str,
// span: expr.span,
// }))
// } else {
// Err(ShellError::TypeMismatch {
// err_message: "string".into(),
// span: expr.span,
// })
// }
// } else {
// Ok(None)
// }
// }
//
// let config_file = extract_contents(config_file)?;

if call.has_flag(engine_state, &mut stack, "version")? {
let version = env!("CARGO_PKG_VERSION").to_string();
Expand All @@ -116,7 +117,7 @@ pub(crate) fn parse_commandline_args(
}

return Ok(NurCliArgs {
config_file,
// config_file,
list_tasks,
quiet_execution,
attach_stdin,
Expand All @@ -141,7 +142,7 @@ pub(crate) fn parse_commandline_args(

#[derive(Debug)]
pub(crate) struct NurCliArgs {
pub(crate) config_file: Option<Spanned<String>>,
// pub(crate) config_file: Option<Spanned<String>>,
pub(crate) list_tasks: bool,
pub(crate) quiet_execution: bool,
pub(crate) attach_stdin: bool,
Expand Down
12 changes: 6 additions & 6 deletions src/commands/nur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ impl Command for Nur {

signature = signature.usage("nu run - simple task runner.")
.allows_unknown_args()
.named(
"config",
SyntaxShape::String,
"path to config",
None,
)
// .named(
// "config",
// SyntaxShape::String,
// "path to config",
// None,
// )
.switch(
"version",
"output version number and exit",
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ fn main() -> Result<(), miette::ErrReport> {
));
}

if parsed_nur_args.config_file.is_some() {
eprintln!("WARNING: Config files are not supported yet.")
}
// if parsed_nur_args.config_file.is_some() {
// eprintln!("WARNING: Config files are not supported yet.")
// }

// Set up the $nu constant before evaluating any files (need to have $nu available in them)
let nu_const = create_nu_constant(&engine_state, PipelineData::empty().span().unwrap_or_else(Span::unknown))?;
Expand Down

0 comments on commit 980d862

Please sign in to comment.