ignore JetBrains IDEs, tidy-up imports (#348)

* ignore JB IDEs

* tidy-up imports

* add rustfmt config
This commit is contained in:
Jakub Panek 2022-04-28 17:53:59 +00:00 committed by GitHub
parent 2cb4cb3982
commit 93ab4e7842
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 129 additions and 117 deletions

3
.gitignore vendored
View file

@ -1,3 +1,6 @@
/target /target
*/target */target
.env .env
# JetBrains IDEs
.idea/

4
.rustfmt.toml Normal file
View file

@ -0,0 +1,4 @@
reorder_imports = true
# uncomment once stable
#imports_granularity = "crate"
#group_imports = "StdExternalCrate"

View file

@ -2,8 +2,10 @@ use std::collections::HashMap;
use chrono::Utc; use chrono::Utc;
use eyre::{bail, Result}; use eyre::{bail, Result};
use reqwest::header::{HeaderMap, AUTHORIZATION, USER_AGENT}; use reqwest::{
use reqwest::{StatusCode, Url}; header::{HeaderMap, AUTHORIZATION, USER_AGENT},
StatusCode, Url,
};
use sodiumoxide::crypto::secretbox; use sodiumoxide::crypto::secretbox;
use atuin_common::api::{ use atuin_common::api::{
@ -11,9 +13,11 @@ use atuin_common::api::{
SyncHistoryResponse, SyncHistoryResponse,
}; };
use crate::encryption::{decode_key, decrypt}; use crate::{
use crate::history::History; encryption::{decode_key, decrypt},
use crate::sync::hash_str; history::History,
sync::hash_str,
};
static APP_USER_AGENT: &str = concat!("atuin/", env!("CARGO_PKG_VERSION"),); static APP_USER_AGENT: &str = concat!("atuin/", env!("CARGO_PKG_VERSION"),);

View file

@ -1,10 +1,7 @@
use std::env; use std::{env, path::Path, str::FromStr};
use std::path::Path;
use std::str::FromStr;
use async_trait::async_trait; use async_trait::async_trait;
use chrono::prelude::*; use chrono::{prelude::*, Utc};
use chrono::Utc;
use fs_err as fs; use fs_err as fs;
use itertools::Itertools; use itertools::Itertools;
use lazy_static::lazy_static; use lazy_static::lazy_static;
@ -15,9 +12,11 @@ use sqlx::{
Result, Row, Result, Row,
}; };
use super::history::History; use super::{
use super::ordering; history::History,
use super::settings::{FilterMode, SearchMode}; ordering,
settings::{FilterMode, SearchMode},
};
pub struct Context { pub struct Context {
session: String, session: String,

View file

@ -8,16 +8,14 @@
// clients must share the secret in order to be able to sync, as it is needed // clients must share the secret in order to be able to sync, as it is needed
// to decrypt // to decrypt
use fs_err as fs; use std::{io::prelude::*, path::PathBuf};
use serde::{Deserialize, Serialize};
use std::io::prelude::*;
use std::path::PathBuf;
use eyre::{eyre, Context, Result}; use eyre::{eyre, Context, Result};
use fs_err as fs;
use serde::{Deserialize, Serialize};
use sodiumoxide::crypto::secretbox; use sodiumoxide::crypto::secretbox;
use crate::history::History; use crate::{history::History, settings::Settings};
use crate::settings::Settings;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct EncryptedHistory { pub struct EncryptedHistory {

View file

@ -1,9 +1,9 @@
use std::env; use std::env;
use chrono::Utc; use chrono::Utc;
use serde::{Deserialize, Serialize};
use atuin_common::utils::uuid_v4; use atuin_common::utils::uuid_v4;
use serde::{Deserialize, Serialize};
// Any new fields MUST be Optional<>! // Any new fields MUST be Optional<>!
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, sqlx::FromRow)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, sqlx::FromRow)]

View file

@ -7,8 +7,7 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use chrono::prelude::*; use chrono::{prelude::*, Utc};
use chrono::Utc;
use directories::BaseDirs; use directories::BaseDirs;
use eyre::{eyre, Result}; use eyre::{eyre, Result};

View file

@ -1,5 +1,7 @@
use std::io::{BufRead, BufReader, Read, Seek, SeekFrom}; use std::{
use std::path::{Path, PathBuf}; io::{BufRead, BufReader, Read, Seek, SeekFrom},
path::{Path, PathBuf},
};
use eyre::Result; use eyre::Result;

View file

@ -4,12 +4,13 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use atuin_common::utils::uuid_v4;
use chrono::{TimeZone, Utc}; use chrono::{TimeZone, Utc};
use directories::UserDirs; use directories::UserDirs;
use eyre::{eyre, Result}; use eyre::{eyre, Result};
use serde::Deserialize; use serde::Deserialize;
use atuin_common::utils::uuid_v4;
use super::{count_lines, Importer}; use super::{count_lines, Importer};
use crate::history::History; use crate::history::History;

View file

@ -7,8 +7,7 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use chrono::prelude::*; use chrono::{prelude::*, Utc};
use chrono::Utc;
use directories::UserDirs; use directories::UserDirs;
use eyre::{eyre, Result}; use eyre::{eyre, Result};
use itertools::Itertools; use itertools::Itertools;

View file

@ -1,7 +1,7 @@
use super::history::History;
use super::settings::SearchMode;
use minspan::minspan; use minspan::minspan;
use super::{history::History, settings::SearchMode};
pub fn reorder_fuzzy(mode: SearchMode, query: &str, res: Vec<History>) -> Vec<History> { pub fn reorder_fuzzy(mode: SearchMode, query: &str, res: Vec<History>) -> Vec<History> {
match mode { match mode {
SearchMode::Fuzzy => reorder(query, |x| &x.command, res), SearchMode::Fuzzy => reorder(query, |x| &x.command, res),

View file

@ -1,13 +1,14 @@
use fs_err::{create_dir_all, File}; use std::{
use serde::Deserialize; io::prelude::*,
use std::io::prelude::*; path::{Path, PathBuf},
use std::path::{Path, PathBuf}; };
use chrono::prelude::*; use chrono::{prelude::*, Utc};
use chrono::Utc;
use config::{Config, Environment, File as ConfigFile, FileFormat}; use config::{Config, Environment, File as ConfigFile, FileFormat};
use eyre::{eyre, Context, Result}; use eyre::{eyre, Context, Result};
use fs_err::{create_dir_all, File};
use parse_duration::parse; use parse_duration::parse;
use serde::Deserialize;
pub const HISTORY_PAGE_SIZE: i64 = 100; pub const HISTORY_PAGE_SIZE: i64 = 100;

View file

@ -5,10 +5,12 @@ use eyre::Result;
use atuin_common::api::AddHistoryRequest; use atuin_common::api::AddHistoryRequest;
use crate::api_client; use crate::{
use crate::database::Database; api_client,
use crate::encryption::{encrypt, load_encoded_key, load_key}; database::Database,
use crate::settings::{Settings, HISTORY_PAGE_SIZE}; encryption::{encrypt, load_encoded_key, load_key},
settings::{Settings, HISTORY_PAGE_SIZE},
};
pub fn hash_str(string: &str) -> String { pub fn hash_str(string: &str) -> String {
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};

View file

@ -1,16 +1,16 @@
use async_trait::async_trait;
use std::collections::HashMap; use std::collections::HashMap;
use tracing::{debug, instrument};
use sqlx::{postgres::PgPoolOptions, Result};
use crate::settings::HISTORY_PAGE_SIZE;
use super::calendar::{TimePeriod, TimePeriodInfo};
use super::models::{History, NewHistory, NewSession, NewUser, Session, User};
use async_trait::async_trait;
use chrono::{Datelike, TimeZone}; use chrono::{Datelike, TimeZone};
use chronoutil::RelativeDuration; use chronoutil::RelativeDuration;
use sqlx::{postgres::PgPoolOptions, Result};
use tracing::{debug, instrument};
use super::{
calendar::{TimePeriod, TimePeriodInfo},
models::{History, NewHistory, NewSession, NewUser, Session, User},
};
use crate::settings::HISTORY_PAGE_SIZE;
use atuin_common::utils::get_days_from_month; use atuin_common::utils::get_days_from_month;

View file

@ -1,16 +1,20 @@
use axum::extract::Query;
use axum::{extract::Path, Extension, Json};
use http::StatusCode;
use std::collections::HashMap; use std::collections::HashMap;
use axum::{
extract::{Path, Query},
Extension, Json,
};
use http::StatusCode;
use tracing::{debug, error, instrument}; use tracing::{debug, error, instrument};
use crate::database::{Database, Postgres};
use crate::models::{NewHistory, User};
use atuin_common::api::*;
use crate::calendar::{TimePeriod, TimePeriodInfo};
use super::{ErrorResponse, ErrorResponseStatus}; use super::{ErrorResponse, ErrorResponseStatus};
use crate::{
calendar::{TimePeriod, TimePeriodInfo},
database::{Database, Postgres},
models::{NewHistory, User},
};
use atuin_common::api::*;
#[instrument(skip_all, fields(user.id = user.id))] #[instrument(skip_all, fields(user.id = user.id))]
pub async fn count( pub async fn count(

View file

@ -1,6 +1,7 @@
use std::borrow::Cow;
use axum::{response::IntoResponse, Json}; use axum::{response::IntoResponse, Json};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::borrow::Cow;
pub mod history; pub mod history;
pub mod user; pub mod user;

View file

@ -1,18 +1,19 @@
use std::borrow::Borrow; use std::borrow::Borrow;
use atuin_common::api::*; use axum::{extract::Path, Extension, Json};
use axum::extract::Path;
use axum::{Extension, Json};
use http::StatusCode; use http::StatusCode;
use sodiumoxide::crypto::pwhash::argon2id13; use sodiumoxide::crypto::pwhash::argon2id13;
use tracing::{debug, error, instrument}; use tracing::{debug, error, instrument};
use uuid::Uuid; use uuid::Uuid;
use crate::database::{Database, Postgres};
use crate::models::{NewSession, NewUser};
use crate::settings::Settings;
use super::{ErrorResponse, ErrorResponseStatus}; use super::{ErrorResponse, ErrorResponseStatus};
use crate::{
database::{Database, Postgres},
models::{NewSession, NewUser},
settings::Settings,
};
use atuin_common::api::*;
pub fn verify_str(secret: &str, verify: &str) -> bool { pub fn verify_str(secret: &str, verify: &str) -> bool {
sodiumoxide::init().unwrap(); sodiumoxide::init().unwrap();

View file

@ -1,10 +1,9 @@
use fs_err::{create_dir_all, File}; use std::{io::prelude::*, path::PathBuf};
use serde::{Deserialize, Serialize};
use std::io::prelude::*;
use std::path::PathBuf;
use config::{Config, Environment, File as ConfigFile, FileFormat}; use config::{Config, Environment, File as ConfigFile, FileFormat};
use eyre::{eyre, Result}; use eyre::{eyre, Result};
use fs_err::{create_dir_all, File};
use serde::{Deserialize, Serialize};
pub const HISTORY_PAGE_SIZE: i64 = 100; pub const HISTORY_PAGE_SIZE: i64 = 100;

View file

@ -1,11 +1,10 @@
use clap::CommandFactory; use std::path::PathBuf;
use clap::Subcommand;
use clap_complete::Shell; use clap::{CommandFactory, Subcommand};
use clap_complete::{generate, generate_to}; use clap_complete::{generate, generate_to, Shell};
use eyre::{Result, WrapErr}; use eyre::{Result, WrapErr};
use atuin_client::database::Sqlite; use atuin_client::{database::Sqlite, settings::Settings};
use atuin_client::settings::Settings;
use atuin_common::utils::uuid_v4; use atuin_common::utils::uuid_v4;
#[cfg(feature = "sync")] #[cfg(feature = "sync")]
@ -18,8 +17,6 @@ mod init;
mod search; mod search;
mod stats; mod stats;
use std::path::PathBuf;
#[derive(Subcommand)] #[derive(Subcommand)]
#[clap(infer_subcommands = true)] #[clap(infer_subcommands = true)]
pub enum Cmd { pub enum Cmd {

View file

@ -1,9 +1,7 @@
use std::thread; use std::{thread, time::Duration};
use std::time::Duration;
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use termion::event::Key; use termion::{event::Key, input::TermRead};
use termion::input::TermRead;
pub enum Event<I> { pub enum Event<I> {
Input(I), Input(I),

View file

@ -1,13 +1,17 @@
use std::env; use std::{
use std::io::{StdoutLock, Write}; env,
use std::time::Duration; io::{StdoutLock, Write},
time::Duration,
};
use clap::Subcommand; use clap::Subcommand;
use eyre::Result; use eyre::Result;
use atuin_client::database::{current_context, Database}; use atuin_client::{
use atuin_client::history::History; database::{current_context, Database},
use atuin_client::settings::Settings; history::History,
settings::Settings,
};
#[cfg(feature = "sync")] #[cfg(feature = "sync")]
use atuin_client::sync; use atuin_client::sync;

View file

@ -1,14 +1,15 @@
use std::{env, path::PathBuf}; use std::{env, path::PathBuf};
use atuin_client::import::fish::Fish;
use clap::Parser; use clap::Parser;
use eyre::{eyre, Result}; use eyre::{eyre, Result};
use atuin_client::import::{bash::Bash, zsh::Zsh};
use atuin_client::{database::Database, import::Importer};
use atuin_client::{history::History, import::resh::Resh};
use indicatif::ProgressBar; use indicatif::ProgressBar;
use atuin_client::{
database::Database,
history::History,
import::{bash::Bash, fish::Fish, resh::Resh, zsh::Zsh, Importer},
};
#[derive(Parser)] #[derive(Parser)]
#[clap(infer_subcommands = true)] #[clap(infer_subcommands = true)]
pub enum Cmd { pub enum Cmd {

View file

@ -1,8 +1,8 @@
use std::{env, io::stdout, ops::Sub, time::Duration};
use chrono::Utc; use chrono::Utc;
use clap::Parser; use clap::Parser;
use eyre::Result; use eyre::Result;
use std::env;
use std::{io::stdout, ops::Sub, time::Duration};
use termion::{event::Key, input::MouseTerminal, raw::IntoRawMode, screen::AlternateScreen}; use termion::{event::Key, input::MouseTerminal, raw::IntoRawMode, screen::AlternateScreen};
use tui::{ use tui::{
backend::{Backend, TermionBackend}, backend::{Backend, TermionBackend},
@ -22,8 +22,10 @@ use atuin_client::{
settings::{FilterMode, SearchMode, Settings}, settings::{FilterMode, SearchMode, Settings},
}; };
use super::event::{Event, Events}; use super::{
use super::history::ListMode; event::{Event, Events},
history::ListMode,
};
const VERSION: &str = env!("CARGO_PKG_VERSION"); const VERSION: &str = env!("CARGO_PKG_VERSION");

View file

@ -1,16 +1,16 @@
use std::collections::HashMap; use std::collections::HashMap;
use chrono::prelude::*; use chrono::{prelude::*, Duration};
use chrono::Duration;
use chrono_english::parse_date_string; use chrono_english::parse_date_string;
use clap::Parser; use clap::Parser;
use cli_table::{format::Justify, print_stdout, Cell, Style, Table}; use cli_table::{format::Justify, print_stdout, Cell, Style, Table};
use eyre::{bail, Result}; use eyre::{bail, Result};
use atuin_client::database::{current_context, Database}; use atuin_client::{
use atuin_client::history::History; database::{current_context, Database},
use atuin_client::settings::{FilterMode, Settings}; history::History,
settings::{FilterMode, Settings},
};
#[derive(Parser)] #[derive(Parser)]
#[clap(infer_subcommands = true)] #[clap(infer_subcommands = true)]

View file

@ -1,8 +1,7 @@
use atuin_client::database::Database;
use clap::Subcommand; use clap::Subcommand;
use eyre::{Result, WrapErr}; use eyre::{Result, WrapErr};
use atuin_client::settings::Settings; use atuin_client::{database::Database, settings::Settings};
mod login; mod login;
mod logout; mod logout;

View file

@ -1,13 +1,11 @@
use std::io; use std::io;
use atuin_common::api::LoginRequest; use clap::{AppSettings, Parser};
use clap::AppSettings;
use clap::Parser;
use eyre::Result; use eyre::Result;
use tokio::{fs::File, io::AsyncWriteExt}; use tokio::{fs::File, io::AsyncWriteExt};
use atuin_client::api_client; use atuin_client::{api_client, settings::Settings};
use atuin_client::settings::Settings; use atuin_common::api::LoginRequest;
#[derive(Parser)] #[derive(Parser)]
#[clap(setting(AppSettings::DeriveDisplayOrder))] #[clap(setting(AppSettings::DeriveDisplayOrder))]

View file

@ -1,10 +1,8 @@
use clap::AppSettings; use clap::{AppSettings, Parser};
use clap::Parser;
use eyre::Result; use eyre::Result;
use tokio::{fs::File, io::AsyncWriteExt}; use tokio::{fs::File, io::AsyncWriteExt};
use atuin_client::api_client; use atuin_client::{api_client, settings::Settings};
use atuin_client::settings::Settings;
#[derive(Parser)] #[derive(Parser)]
#[clap(setting(AppSettings::DeriveDisplayOrder))] #[clap(setting(AppSettings::DeriveDisplayOrder))]

View file

@ -3,8 +3,7 @@ use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use clap::Parser; use clap::Parser;
use eyre::{Context, Result}; use eyre::{Context, Result};
use atuin_server::launch; use atuin_server::{launch, settings::Settings};
use atuin_server::settings::Settings;
#[derive(Parser)] #[derive(Parser)]
#[clap(infer_subcommands = true)] #[clap(infer_subcommands = true)]

View file

@ -1,8 +1,7 @@
#![warn(clippy::pedantic, clippy::nursery)] #![warn(clippy::pedantic, clippy::nursery)]
#![allow(clippy::use_self)] // not 100% reliable #![allow(clippy::use_self)] // not 100% reliable
use clap::AppSettings; use clap::{AppSettings, Parser};
use clap::Parser;
use eyre::Result; use eyre::Result;
#[macro_use] #[macro_use]