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

add configuration #81

Merged
merged 7 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 184 additions & 5 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ sysinfo = "0.31"
listeners = "0.2.1"
chrono = "0.4"
clap = { version = "4.5", features = ["derive"] }
directories = "5.0"
toml = "0.8"
serde = { version = "1.0", features = ["derive"] }
fuzzy-matcher = "0.3.7"

[dev-dependencies]
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ cargo binstall pik

## Configuration

### Application configuration

You may set your preferences in `pik.toml` file located in `~/.config/pik` directory.
All options are optional, if skipped default values will be used.
Example configuration with default settings can be found at [example config](example_config.toml)

### Key maps

- Esc | Ctrl + C - Quit
Expand Down
3 changes: 3 additions & 0 deletions example_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Size of the viewport
screen_size = { height = 20 } # run pik in 20 lines of the terminal
# screen_size = "fullscreen" # run pik in fullscreen
23 changes: 17 additions & 6 deletions src/args.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use clap::Parser;
use clap::{Args, Parser};

use crate::config;

#[derive(Parser, Debug)]
#[command(version, about, long_about = Some("Pik is a simple TUI tool for searching and killing processes in interactive way."))]
pub struct Args {
pub struct CliArgs {
#[clap(
default_value = "",
help = r#"Query string for searching processes. By default, all processes are searched.
help = r#"Query string for searching processes.
You may use special prefix for different kind of search:
- :<port> - search by port, i.e ':8080'
- /<path> - search by command path, i.e. '/home/user/bin'
Expand All @@ -17,10 +19,19 @@ pub struct Args {
#[arg(short = 't', long, default_value_t = false)]
pub include_threads_processes: bool,
/// By default pik shows only proceseses owned by current user. This flag allows to show all processes
#[arg(short, long, default_value_t = false)]
pub all_processes: bool,
#[arg(short = 'a', long, default_value_t = false)]
pub include_other_users_processes: bool,
#[command(flatten)]
pub screen_size: Option<ScreenSizeOptions>,
}

#[derive(Args, Debug, Clone, Copy)]
#[group(required = false, multiple = false)]
pub struct ScreenSizeOptions {
/// Start pik in fullscreen mode
#[arg(short = 'F', long, default_value_t = false)]
pub fullscreen: bool,
#[arg(short = 'H', long, default_value_t = 20)]
/// Number of lines of the screen pik will use
#[arg(short = 'H', long, default_value_t = config::DEFAULT_SCREEN_SIZE)]
pub height: u16,
}
Loading