Skip to content

Commit 74f9251

Browse files
committed
don't save options automaticly, add new command to save options
1 parent 5a7e32e commit 74f9251

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

crates/irust/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ You can try out IRust with no installation or setup (via Gitpod.io) by visiting
6464

6565
**:exit** | **:quit** => Exit IRust immediately
6666

67+
**:save_options** => save the options to disk (useful when options where changed at runtime)
68+
6769
**$$** => Shell commands can be interpolated with rust code with '$$', for example: `let a = $$ls -l$$;`, this feature can be [en/dis]abled via the config file
6870

6971
**::** => run a shell command, example `::ls`

crates/irust/src/irust/engine.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ pub struct Engine {
2828
macros: HashMap<char, Vec<Command>>,
2929
buffers: Vec<Buffer>,
3030
buffers_idx: usize,
31-
// defaults to false
32-
pub dont_save_options: bool,
3331
}
3432

3533
impl IRust {
@@ -680,9 +678,6 @@ impl IRust {
680678
// Give scripts a chance to clean-up
681679
self.run_scripts_shutdown_cmds()?;
682680
self.history.save()?;
683-
if !self.engine.dont_save_options {
684-
self.options.save()?;
685-
}
686681
self.printer.write_newline(&self.buffer);
687682
self.printer.cursor.show();
688683
Ok(())

crates/irust/src/irust/options.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ impl IRust {
182182
|| (shell_cmd && self.options.add_shell_cmd_to_history)
183183
|| (!irust_cmd && !shell_cmd)
184184
}
185-
pub fn dont_save_options(&mut self) {
186-
self.engine.dont_save_options = true;
187-
}
188185
}
189186

190187
#[allow(clippy::upper_case_acronyms)]

crates/irust/src/irust/parser.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ impl IRust {
5252
":irust" => self.irust(),
5353
":sync" => self.sync(),
5454
":exit" | ":quit" => self.exit(),
55+
":save_options" => self.save_options(),
5556
cmd if cmd.starts_with(":help") => self.help(buffer),
5657
cmd if cmd.starts_with("::") => self.run_cmd(buffer),
5758
cmd if cmd.starts_with(":edit") => self.extern_edit(buffer),
@@ -1041,6 +1042,11 @@ impl IRust {
10411042
self.exit_flag = true;
10421043
Ok(PrintQueue::default())
10431044
}
1045+
1046+
fn save_options(&mut self) -> Result<PrintQueue> {
1047+
self.options.save()?;
1048+
success!()
1049+
}
10441050
}
10451051

10461052
// These patterns are used to detect statements that don't require to be terminated with ';'

crates/irust/src/irust/ra.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct Completer {
2323
// suggestions: (Name, definition)
2424
suggestions: Vec<(String, String)>,
2525
suggestion_idx: usize,
26-
cmds: [String; 30],
26+
cmds: [String; 31],
2727
update_lock: bool,
2828
pub active_suggestion: Option<String>,
2929
}
@@ -53,6 +53,7 @@ impl Completer {
5353
"toolchain".to_string(),
5454
"theme".to_string(),
5555
"main_result".to_string(),
56+
"save_options".to_string(),
5657
"check_statements".to_string(),
5758
"time_release".to_string(),
5859
"time".to_string(),

crates/irust/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ fn main() {
7777

7878
// Create main IRust interface
7979
let mut irust = if matches!(args_result, ArgsResult::ProceedWithDefaultConfig) {
80-
let mut irust = IRust::new(Options::default());
81-
irust.dont_save_options();
82-
irust
80+
IRust::new(Options::default())
8381
} else {
8482
// Check optional dependencies and warn if they're not present
8583
if !cfg!(feature = "no-welcome-screen") {

0 commit comments

Comments
 (0)