Skip to content

Commit

Permalink
Merges PR #8, bumps version
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorrFG committed Nov 16, 2023
1 parent a4b0399 commit 9f7a3a8
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dotree"
version = "0.6.0"
version = "0.7.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion grammar.pest
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cmd_body = { ((cmd_settings|vars_def|shell_def) ~ NEWLINE)* ~ quick_command }
vars_def = { "vars" ~ var_def ~ (DEF_SEP* ~ var_def)* }
DEF_SEP = _{"," ~ NEWLINE*}
var_def = { symbol ~ default_var? }
default_var = { "=" ~ normal_string }
default_var = { "=" ~ string }
cmd_settings = { "set" ~ symbol ~ (DEF_SEP* ~ symbol)* }

shell_def = {"shell" ~ (string|word)+ }
Expand Down
4 changes: 2 additions & 2 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ fn query_env_var(
if line.is_empty() {
if let Some(default_val) = default_val {
hist.push(default_val.to_string());
return Ok(hist);
}
} else {
hist.push(line);
}
hist.push(line);
Ok(hist)
}

Expand Down
13 changes: 9 additions & 4 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ fn parse_vars_def(p: Pair<'_, Rule>) -> Vec<VarDef> {
let name = name_def.as_str().to_string();
let value = value_def.map(|v| {
assert!(v.as_rule() == Rule::default_var, "unexpected rule: {p:#?}");
// v(default_var) -> normal_string -> normal_content
v.inext().inext().as_str().to_string()
from_string(v.inext())
});

VarDef { name, value }
Expand Down Expand Up @@ -685,8 +684,14 @@ Config {
name: None,
shell: None,
env_vars: [
"foo",
"bar",
VarDef {
name: "foo",
value: None,
},
VarDef {
name: "bar",
value: None,
},
],
},
),
Expand Down
8 changes: 8 additions & 0 deletions tests/bash_tests/arg_test.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$DT -c arg_test.dt f alpha beta gamma

printf "lala\n" | $DT -c arg_test.dt f alpha beta

printf "\n" | $DT -c arg_test.dt f alpha beta

printf "\n\n\n" | $DT -c arg_test.dt f

6 changes: 6 additions & 0 deletions tests/bash_tests/arg_test.dt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
menu root {
f: cmd {
vars a, b, c="foo"
"echo $a $b $c"
}
}
4 changes: 4 additions & 0 deletions tests/bash_tests/arg_test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[?25l[?25halpha beta gamma
[?25l[?25halpha beta lala
[?25l[?25halpha beta foo
[?25l[?25hfoo
Expand Down

0 comments on commit 9f7a3a8

Please sign in to comment.