Skip to content

Commit 2649981

Browse files
committed
Add complete -u
1 parent fbba56c commit 2649981

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/core.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub struct ShellCore {
4747
pub job_table_priority: Vec<usize>,
4848
current_dir: Option<path::PathBuf>, // the_current_working_directory
4949
pub completion_functions: HashMap<String, String>,
50+
pub completion_actions: HashMap<String, String>,
5051
pub real_time: TimeSpec,
5152
pub user_time: TimeVal,
5253
pub sys_time: TimeVal,
@@ -88,6 +89,7 @@ impl ShellCore {
8889
job_table_priority: vec![],
8990
current_dir: None,
9091
completion_functions: HashMap::new(),
92+
completion_actions: HashMap::new(),
9193
real_time: TimeSpec::new(0, 0),
9294
user_time: TimeVal::new(0, 0),
9395
sys_time: TimeVal::new(0, 0),

src/core/builtins/completion.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,19 @@ fn compgen_u(_: &mut ShellCore, args: &mut Vec<String>) -> Vec<String> {
229229
}
230230

231231
pub fn complete(core: &mut ShellCore, args: &mut Vec<String>) -> i32 {
232-
if args.len() < 4 || args[1] != "-F" {
233-
eprintln!("sush: {}: still unsupported", &args[0]);
234-
return 1;
232+
if args.len() > 2 && args[1] == "-u" {
233+
for command in &args[2..] {
234+
core.completion_functions.insert(command.clone(), "user".to_string());
235+
}
235236
}
237+
//&& (args.len() > 3 && args[1] == "-A" && args[2] == "user") {
238+
//}
236239

237-
core.completion_functions.insert(args[3].clone(), args[2].clone());
238-
0
240+
if args.len() > 3 && args[1] == "-F" {
241+
core.completion_functions.insert(args[3].clone(), args[2].clone());
242+
return 0;
243+
}
244+
245+
eprintln!("sush: {} {}: still unsupported", &args[0], &args[1]);
246+
1
239247
}

src/core/options.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ impl Options {
4141
options.opts.insert(opt.to_string(), false);
4242
}*/
4343

44-
options.opts.insert("extglob".to_string(), true);
44+
let true_list = ["extglob", "progcomp"];
45+
for opt in true_list {
46+
options.opts.insert(opt.to_string(), true);
47+
}
4548

4649
options
4750
}

0 commit comments

Comments
 (0)