Skip to content

Commit

Permalink
upgrade dep libs
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Wang committed Oct 4, 2019
1 parent e8b33bb commit 1c402f7
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@
- Updated math arithmetic recognize rule.
- In scripting, test head's status should not be catched.
- Fixed a completion issue like `echo $USER /App<TAB>`.
- Upgraded dependency libs.

## 0.9.8 - 2019-06-20

Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -23,18 +23,18 @@ doc = false
chrono = "0.4"
errno = "0.2.0"
exec = "0.3.0"
glob = "0.2.0"
glob = "0.3.0"
lazy_static = "1.3.0"
libc = "0.2.0"
linefeed = "0.6.0"
nix = "0.14.0"
nix = "0.15.0"
pest = "2.0"
pest_derive = "2.0"
regex = "1"
yaml-rust = "0.4.0"

[dependencies.rusqlite]
version = "0.16.0"
version = "0.20.0"
features = ["bundled"]

[build-dependencies]
Expand Down
19 changes: 12 additions & 7 deletions docs/builtins.md
Expand Up @@ -76,20 +76,25 @@ Bring background job into foreground. See also `bg`, `jobs`.
List your recent history:
```
$ history
0: touch docs/envs.md
1: mvim docs/envs.md
2: find . -name '*.bk' | xargs rm
3: find . -name '*.bk'
1: touch docs/envs.md
2: mvim docs/envs.md
3: find . -name '*.bk' | xargs rm
4: find . -name '*.bk'
```

Search history items (use `%` from SQL to match "anything"):
```
$ history curl
0: curl -x http://127.0.0.1:1080 https://hugo.wang/http/ip/
1: curl -I https://twitter.com/
1: curl -x http://127.0.0.1:1080 https://hugo.wang/http/ip/
2: curl -I https://twitter.com/
$ history 'curl%hugo'
0: curl -x http://127.0.0.1:1080 https://hugo.wang/http/ip/
1: curl -x http://127.0.0.1:1080 https://hugo.wang/http/ip/
```

Delete history items
```
$ history delete <item-id>
```

## jobs
Expand Down
75 changes: 62 additions & 13 deletions src/builtins/history.rs
Expand Up @@ -60,20 +60,44 @@ fn list_current_history(conn: &Conn) -> i32 {
return 1;
}
};
let rows = match stmt.query_map(NO_PARAMS, |row| (row.get(0), row.get(1))) {

let mut rows = match stmt.query(NO_PARAMS) {
Ok(x) => x,
Err(e) => {
println_stderr!("history: query select error: {:?}", e);
println_stderr!("history: query error: {:?}", e);
return 1;
}
};
for x in rows {
if let Ok(xx) = x {
let _x: (i32, String) = xx;
println!("{}: {}", _x.0, _x.1);

loop {
match rows.next() {
Ok(_rows) => {
if let Some(row) = _rows {
let row_id: i32 = match row.get(0) {
Ok(x) => x,
Err(e) => {
println_stderr!("history: error: {:?}", e);
return 1;
}
};
let inp: String = match row.get(1) {
Ok(x) => x,
Err(e) => {
println_stderr!("history: error: {:?}", e);
return 1;
}
};
println!("{}: {}", row_id, inp);
} else {
return 0;
}
}
Err(e) => {
println_stderr!("history: rows next error: {:?}", e);
return 1;
}
}
}
0
}

fn search_history(conn: &Conn, q: &str) {
Expand All @@ -91,17 +115,42 @@ fn search_history(conn: &Conn, q: &str) {
return;
}
};
let rows = match stmt.query_map(NO_PARAMS, |row| (row.get(0), row.get(1))) {

let mut rows = match stmt.query(NO_PARAMS) {
Ok(x) => x,
Err(e) => {
println_stderr!("history: query select error: {:?}", e);
println_stderr!("history: query error: {:?}", e);
return;
}
};
for x in rows {
if let Ok(xx) = x {
let _x: (i32, String) = xx;
println!("{}: {}", _x.0, _x.1);

loop {
match rows.next() {
Ok(_rows) => {
if let Some(row) = _rows {
let row_id: i32 = match row.get(0) {
Ok(x) => x,
Err(e) => {
println_stderr!("history: error: {:?}", e);
return;
}
};
let inp: String = match row.get(1) {
Ok(x) => x,
Err(e) => {
println_stderr!("history: error: {:?}", e);
return;
}
};
println!("{}: {}", row_id, inp);
} else {
return;
}
}
Err(e) => {
println_stderr!("history: rows next error: {:?}", e);
return;
}
}
}
}
Expand Down

0 comments on commit 1c402f7

Please sign in to comment.