Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement 'source' builtin command (#18)
* implement 'source' builtin command * source to throw error if not cicadarc file * add source command to completer, update changelong * 'scripting is a WIP' error if source called on non RC file * forgot to return 1 from source if not cicadarc file
- Loading branch information
Nicholas Klingler
authored and
Hugo Wang
committed
Mar 20, 2019
1 parent
7da18e5
commit 3165323
Showing
7 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ pub mod fg; | |
pub mod history; | ||
pub mod jobs; | ||
pub mod vox; | ||
pub mod source; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::io::Write; | ||
|
||
use crate::shell; | ||
use crate::parsers; | ||
use crate::rcfile; | ||
use crate::types::Tokens; | ||
|
||
|
||
pub fn run(sh: &mut shell::Shell, tokens: &Tokens) -> i32 { | ||
let args = parsers::parser_line::tokens_to_args(&tokens); | ||
if args.len() > 2 { | ||
println_stderr!("cicada: source: too many arguments"); | ||
return 1; | ||
} | ||
if args.len() < 2 { | ||
println_stderr!("cicada: source: no file specified"); | ||
return 1; | ||
} | ||
if !args[1].ends_with("cicadarc") { | ||
println_stderr!("cicada: source command only supports cicadarc files"); | ||
println_stderr!("scripting in cicada is still a work in progress"); | ||
return 1; | ||
} | ||
|
||
rcfile::load_file(sh, &args[1], 1); | ||
0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters