aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client/src
diff options
context:
space:
mode:
authorJakub Panek <me@panekj.dev>2022-04-28 17:53:59 +0000
committerGitHub <noreply@github.com>2022-04-28 18:53:59 +0100
commit93ab4e7842ac3c3a37e8d423ae57ef3e7d151b7b (patch)
treec910b1bb047a540c361f6cb6f8e403f1b83b925a /atuin-client/src
parentBump axum from 0.5.3 to 0.5.4 (#355) (diff)
downloadatuin-93ab4e7842ac3c3a37e8d423ae57ef3e7d151b7b.zip
ignore JetBrains IDEs, tidy-up imports (#348)
* ignore JB IDEs * tidy-up imports * add rustfmt config
Diffstat (limited to 'atuin-client/src')
-rw-r--r--atuin-client/src/api_client.rs14
-rw-r--r--atuin-client/src/database.rs15
-rw-r--r--atuin-client/src/encryption.rs10
-rw-r--r--atuin-client/src/history.rs2
-rw-r--r--atuin-client/src/import/fish.rs3
-rw-r--r--atuin-client/src/import/mod.rs6
-rw-r--r--atuin-client/src/import/resh.rs3
-rw-r--r--atuin-client/src/import/zsh.rs3
-rw-r--r--atuin-client/src/ordering.rs4
-rw-r--r--atuin-client/src/settings.rs13
-rw-r--r--atuin-client/src/sync.rs10
11 files changed, 44 insertions, 39 deletions
diff --git a/atuin-client/src/api_client.rs b/atuin-client/src/api_client.rs
index 528d1611..d0511f8e 100644
--- a/atuin-client/src/api_client.rs
+++ b/atuin-client/src/api_client.rs
@@ -2,8 +2,10 @@ use std::collections::HashMap;
use chrono::Utc;
use eyre::{bail, Result};
-use reqwest::header::{HeaderMap, AUTHORIZATION, USER_AGENT};
-use reqwest::{StatusCode, Url};
+use reqwest::{
+ header::{HeaderMap, AUTHORIZATION, USER_AGENT},
+ StatusCode, Url,
+};
use sodiumoxide::crypto::secretbox;
use atuin_common::api::{
@@ -11,9 +13,11 @@ use atuin_common::api::{
SyncHistoryResponse,
};
-use crate::encryption::{decode_key, decrypt};
-use crate::history::History;
-use crate::sync::hash_str;
+use crate::{
+ encryption::{decode_key, decrypt},
+ history::History,
+ sync::hash_str,
+};
static APP_USER_AGENT: &str = concat!("atuin/", env!("CARGO_PKG_VERSION"),);
diff --git a/atuin-client/src/database.rs b/atuin-client/src/database.rs
index cfd63a3a..5f37e8b1 100644
--- a/atuin-client/src/database.rs
+++ b/atuin-client/src/database.rs
@@ -1,10 +1,7 @@
-use std::env;
-use std::path::Path;
-use std::str::FromStr;
+use std::{env, path::Path, str::FromStr};
use async_trait::async_trait;
-use chrono::prelude::*;
-use chrono::Utc;
+use chrono::{prelude::*, Utc};
use fs_err as fs;
use itertools::Itertools;
use lazy_static::lazy_static;
@@ -15,9 +12,11 @@ use sqlx::{
Result, Row,
};
-use super::history::History;
-use super::ordering;
-use super::settings::{FilterMode, SearchMode};
+use super::{
+ history::History,
+ ordering,
+ settings::{FilterMode, SearchMode},
+};
pub struct Context {
session: String,
diff --git a/atuin-client/src/encryption.rs b/atuin-client/src/encryption.rs
index f805cbd5..842fe9f3 100644
--- a/atuin-client/src/encryption.rs
+++ b/atuin-client/src/encryption.rs
@@ -8,16 +8,14 @@
// clients must share the secret in order to be able to sync, as it is needed
// to decrypt
-use fs_err as fs;
-use serde::{Deserialize, Serialize};
-use std::io::prelude::*;
-use std::path::PathBuf;
+use std::{io::prelude::*, path::PathBuf};
use eyre::{eyre, Context, Result};
+use fs_err as fs;
+use serde::{Deserialize, Serialize};
use sodiumoxide::crypto::secretbox;
-use crate::history::History;
-use crate::settings::Settings;
+use crate::{history::History, settings::Settings};
#[derive(Debug, Serialize, Deserialize)]
pub struct EncryptedHistory {
diff --git a/atuin-client/src/history.rs b/atuin-client/src/history.rs
index c7bf6111..59519143 100644
--- a/atuin-client/src/history.rs
+++ b/atuin-client/src/history.rs
@@ -1,9 +1,9 @@
use std::env;
use chrono::Utc;
+use serde::{Deserialize, Serialize};
use atuin_common::utils::uuid_v4;
-use serde::{Deserialize, Serialize};
// Any new fields MUST be Optional<>!
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, sqlx::FromRow)]
diff --git a/atuin-client/src/import/fish.rs b/atuin-client/src/import/fish.rs
index 70639264..7c05d180 100644
--- a/atuin-client/src/import/fish.rs
+++ b/atuin-client/src/import/fish.rs
@@ -7,8 +7,7 @@ use std::{
path::{Path, PathBuf},
};
-use chrono::prelude::*;
-use chrono::Utc;
+use chrono::{prelude::*, Utc};
use directories::BaseDirs;
use eyre::{eyre, Result};
diff --git a/atuin-client/src/import/mod.rs b/atuin-client/src/import/mod.rs
index 471b7f98..8d4aa17f 100644
--- a/atuin-client/src/import/mod.rs
+++ b/atuin-client/src/import/mod.rs
@@ -1,5 +1,7 @@
-use std::io::{BufRead, BufReader, Read, Seek, SeekFrom};
-use std::path::{Path, PathBuf};
+use std::{
+ io::{BufRead, BufReader, Read, Seek, SeekFrom},
+ path::{Path, PathBuf},
+};
use eyre::Result;
diff --git a/atuin-client/src/import/resh.rs b/atuin-client/src/import/resh.rs
index cd5dccf7..3eea84d7 100644
--- a/atuin-client/src/import/resh.rs
+++ b/atuin-client/src/import/resh.rs
@@ -4,12 +4,13 @@ use std::{
path::{Path, PathBuf},
};
-use atuin_common::utils::uuid_v4;
use chrono::{TimeZone, Utc};
use directories::UserDirs;
use eyre::{eyre, Result};
use serde::Deserialize;
+use atuin_common::utils::uuid_v4;
+
use super::{count_lines, Importer};
use crate::history::History;
diff --git a/atuin-client/src/import/zsh.rs b/atuin-client/src/import/zsh.rs
index b3db36b6..915b3115 100644
--- a/atuin-client/src/import/zsh.rs
+++ b/atuin-client/src/import/zsh.rs
@@ -7,8 +7,7 @@ use std::{
path::{Path, PathBuf},
};
-use chrono::prelude::*;
-use chrono::Utc;
+use chrono::{prelude::*, Utc};
use directories::UserDirs;
use eyre::{eyre, Result};
use itertools::Itertools;
diff --git a/atuin-client/src/ordering.rs b/atuin-client/src/ordering.rs
index 0bb12c6a..4e5ec84c 100644
--- a/atuin-client/src/ordering.rs
+++ b/atuin-client/src/ordering.rs
@@ -1,7 +1,7 @@
-use super::history::History;
-use super::settings::SearchMode;
use minspan::minspan;
+use super::{history::History, settings::SearchMode};
+
pub fn reorder_fuzzy(mode: SearchMode, query: &str, res: Vec<History>) -> Vec<History> {
match mode {
SearchMode::Fuzzy => reorder(query, |x| &x.command, res),
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs
index bb3424a4..f0af4993 100644
--- a/atuin-client/src/settings.rs
+++ b/atuin-client/src/settings.rs
@@ -1,13 +1,14 @@
-use fs_err::{create_dir_all, File};
-use serde::Deserialize;
-use std::io::prelude::*;
-use std::path::{Path, PathBuf};
+use std::{
+ io::prelude::*,
+ path::{Path, PathBuf},
+};
-use chrono::prelude::*;
-use chrono::Utc;
+use chrono::{prelude::*, Utc};
use config::{Config, Environment, File as ConfigFile, FileFormat};
use eyre::{eyre, Context, Result};
+use fs_err::{create_dir_all, File};
use parse_duration::parse;
+use serde::Deserialize;
pub const HISTORY_PAGE_SIZE: i64 = 100;
diff --git a/atuin-client/src/sync.rs b/atuin-client/src/sync.rs
index 23f552e5..4ddaf514 100644
--- a/atuin-client/src/sync.rs
+++ b/atuin-client/src/sync.rs
@@ -5,10 +5,12 @@ use eyre::Result;
use atuin_common::api::AddHistoryRequest;
-use crate::api_client;
-use crate::database::Database;
-use crate::encryption::{encrypt, load_encoded_key, load_key};
-use crate::settings::{Settings, HISTORY_PAGE_SIZE};
+use crate::{
+ api_client,
+ database::Database,
+ encryption::{encrypt, load_encoded_key, load_key},
+ settings::{Settings, HISTORY_PAGE_SIZE},
+};
pub fn hash_str(string: &str) -> String {
use sha2::{Digest, Sha256};