Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crossterm support #331

Merged
merged 6 commits into from Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
104 changes: 62 additions & 42 deletions Cargo.lock

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

8 changes: 6 additions & 2 deletions Cargo.toml
Expand Up @@ -56,8 +56,7 @@ directories = "4"
indicatif = "0.17.1"
serde = { version = "1.0.145", features = ["derive"] }
serde_json = "1.0.86"
tui = { version = "0.19", default-features = false, features = ["termion"] }
termion = "1.5"
crossterm = { version = "0.26", features = ["use-dev-tty"] }
unicode-width = "0.1"
itertools = "0.10.5"
tokio = { version = "1", features = ["full"] }
Expand All @@ -74,6 +73,11 @@ rpassword = "7.0"
semver = "1.0.14"
runtime-format = "0.1.2"

# from tui
bitflags = "1.3"
cassowary = "0.3"
unicode-segmentation = "1.2"

[dependencies.tracing-subscriber]
version = "0.3"
default-features = false
Expand Down
8 changes: 4 additions & 4 deletions atuin-client/src/api_client.rs
Expand Up @@ -42,14 +42,14 @@ pub async fn register(
map.insert("email", email);
map.insert("password", password);

let url = format!("{}/user/{}", address, username);
let url = format!("{address}/user/{username}");
let resp = reqwest::get(url).await?;

if resp.status().is_success() {
bail!("username already in use");
}

let url = format!("{}/register", address);
let url = format!("{address}/register");
let client = reqwest::Client::new();
let resp = client
.post(url)
Expand All @@ -68,7 +68,7 @@ pub async fn register(
}

pub async fn login(address: &str, req: LoginRequest) -> Result<LoginResponse> {
let url = format!("{}/login", address);
let url = format!("{address}/login");
let client = reqwest::Client::new();

let resp = client
Expand Down Expand Up @@ -111,7 +111,7 @@ pub async fn latest_version() -> Result<Version> {
impl<'a> Client<'a> {
pub fn new(sync_addr: &'a str, session_token: &'a str, key: String) -> Result<Self> {
let mut headers = HeaderMap::new();
headers.insert(AUTHORIZATION, format!("Token {}", session_token).parse()?);
headers.insert(AUTHORIZATION, format!("Token {session_token}").parse()?);

Ok(Client {
sync_addr,
Expand Down
3 changes: 2 additions & 1 deletion atuin-client/src/database.rs
Expand Up @@ -448,7 +448,8 @@ impl Database for Sqlite {
} else if let Some(term) = query_part.strip_prefix('\'') {
format!("{glob}{term}{glob}")
} else if is_inverse {
format!("{glob}{term}{glob}", term = query_part)
let term = query_part;
format!("{glob}{term}{glob}")
} else {
query_part.split("").join(glob)
};
Expand Down
2 changes: 1 addition & 1 deletion atuin-client/src/import/fish.rs
Expand Up @@ -31,7 +31,7 @@ fn default_histpath() -> Result<PathBuf> {
};

let mut histpath = data.join("fish");
histpath.push(format!("{}_history", session));
histpath.push(format!("{session}_history"));

if histpath.exists() {
Ok(histpath)
Expand Down
2 changes: 1 addition & 1 deletion atuin-client/src/import/zsh_histdb.rs
Expand Up @@ -221,7 +221,7 @@ mod test {
println!("h: {:#?}", histdb.histdb);
println!("counter: {:?}", histdb.histdb.len());
for i in histdb.histdb {
println!("{:?}", i);
println!("{i:?}");
}
}
}
5 changes: 2 additions & 3 deletions atuin-client/src/settings.rs
Expand Up @@ -262,9 +262,8 @@ impl Settings {
let data_dir = atuin_common::utils::data_dir();

create_dir_all(&config_dir)
.wrap_err_with(|| format!("could not create dir {:?}", config_dir))?;
create_dir_all(&data_dir)
.wrap_err_with(|| format!("could not create dir {:?}", data_dir))?;
.wrap_err_with(|| format!("could not create dir {config_dir:?}"))?;
create_dir_all(&data_dir).wrap_err_with(|| format!("could not create dir {data_dir:?}"))?;

let mut config_file = if let Ok(p) = std::env::var("ATUIN_CONFIG_DIR") {
PathBuf::from(p)
Expand Down
3 changes: 1 addition & 2 deletions src/command/client/history.rs
Expand Up @@ -257,8 +257,7 @@ impl Cmd {
}
(Some(session), Some(cwd)) => {
let query = format!(
"select * from history where cwd = '{}' and session = '{}';",
cwd, session
"select * from history where cwd = '{cwd}' and session = '{session}';"
);
db.query_history(&query).await?
}
Expand Down
1 change: 0 additions & 1 deletion src/command/client/search.rs
Expand Up @@ -13,7 +13,6 @@ use super::history::ListMode;

mod cursor;
mod duration;
mod event;
mod history_list;
mod interactive;
pub use duration::{format_duration, format_duration_into};
Expand Down
70 changes: 0 additions & 70 deletions src/command/client/search/event.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/command/client/search/history_list.rs
@@ -1,12 +1,12 @@
use std::time::Duration;

use atuin_client::history::History;
use tui::{
use crate::tui::{
buffer::Buffer,
layout::Rect,
style::{Color, Modifier, Style},
widgets::{Block, StatefulWidget, Widget},
};
use atuin_client::history::History;

use super::format_duration;

Expand Down