1use crate::config::Config;
9
10pub enum CliAction {
11 RunApp,
12 Exit,
13}
14
15pub fn handle_args() -> CliAction {
16 let args: Vec<String> = std::env::args().collect();
17 let config_path = Config::default_path();
18
19 if args.len() <= 1 {
20 return CliAction::RunApp;
21 }
22
23 match args[1].as_str() {
24 "-h" | "--help" => {
25 print_help();
26 CliAction::Exit
27 }
28 "--config-help" => {
29 print_config_help();
30 CliAction::Exit
31 }
32 "--init" => {
33 if let Err(e) = Config::generate_default(&config_path, true) {
34 eprintln!("Error: {}", e);
35 }
36 CliAction::Exit
37 }
38 "--init-full" => {
39 if let Err(e) = Config::generate_default(&config_path, false) {
40 eprintln!("Error: {}", e);
41 }
42 CliAction::Exit
43 }
44 arg => {
45 eprintln!("Unknown argument: {}", arg);
46 CliAction::Exit
47 }
48 }
49}
50
51fn print_help() {
52 println!(
53 r#"runa - A fast and lightweight console file browser written in Rust
54
55USAGE:
56 rn [OPTIONS]
57
58OPTIONS:
59 --help, -h Print help information
60 --init Generate full default config at ~/.config/runa/runa.toml
61 --init-minimal Generate minimal config (overrides only)
62 --config-help Display all the configuration options
63
64ENVIRONMENT:
65 RUNA_CONFIG Override the default config path
66"#
67 );
68}
69
70fn print_config_help() {
71 let help_text = r##"
72runa - Full Configuration Guide (runa.toml)
73
74# General Settings
75 dirs_first (bool) Sort directories before files
76 show_hidden (bool) Show hidden files (dotfiles)
77 show_system (bool) Show system/protected files. Mostly usefull for Windows.
78 case_insensitive (bool) Ignore case when searching/sorting
79 always_show (list) List of hidden names to always show
80
81[display]
82 selection_marker (bool) Show the cursor marker
83 dir_marker (bool) Show a marker for directories
84 borders (str) "none", "unified", or "split"
85 border_shape (str) "square", "rounded" or "double"
86 titles (bool) Show pane titles at the top
87 separators (bool) Draw vertical lines between panes
88 parent (bool) Show the parent directory pane
89 preview (bool) Show the file preview pane
90 preview_underline (bool) Use underline for preview selection instead of a highlighted selection
91 preview_underline_color (bool) Use underline colors instead of selection colors
92 entry_padding (usize) Entry padding for all the panes
93 scroll_padding (usize) Scroll padding of the main pane
94
95[display.layout]
96 parent (u16) Width % of the parent pane
97 main (u16) Width % of the center pane
98 preview (u16) Width % of the preview pane
99
100[display.info] Toggle the file info attributes
101 name (bool)
102 file_type (bool)
103 size (bool)
104 modified (bool)
105 perms (bool)
106
107[theme]
108 selection_icon (str) The cursor string (e.g., "> ")
109
110# Theme sections (Each supports "fg" and "bg" keys,)
111[theme.selection] Selection bar colors fg (str), bg (str)
112[theme.accent] Border/title accents fg (str), bg (str)
113[theme.entry] Standard entry colors fg (str), bg (str)
114[theme.directory] Directory entry colors fg (str), bg (str)
115[theme.separator] Vertical line colors fg (str), bg (str)
116[theme.parent] Parent pane text fg (str), bg (str)
117[theme.preview] Preview pane text fg (str), bg (str)
118[theme.path] Path bar colors fg (str), bg (str)
119[theme.underline] Underline colors fg (str), bg (str)
120[theme.widget] Global dialog/widgets
121 position (str/list/table) "center", "top_left", [x, y], { x, y }
122 size (str/list/table) "small", "medium", [w, h], { w, h }
123 confirm_size (str/list/table) Size for confirmation dialogs
124 color.fg/bg (str)
125 border.fg/bg (str)
126 title.fg/bg (str)
127# Supported: dot notation (color.fg) or [theme.widget.color] subtables
128
129[theme.info] File info overlay
130 color.fg/bg, (str)
131 border.fg/bg, (str)
132 title.fg/bg, (str)
133 position (str/list/table) "center", "top_left", [x, y], { x, y }
134
135[editor]
136 cmd (str) Command to open files (e.g., "nvim")
137
138[keys]
139 open_file (list) e.g., ["Enter"]
140 go_up (list) e.g., ["k", "Up"]
141 go_down (list) e.g., ["j", "Down"]
142 go_parent (list) e.g., ["h", "Left", "Backspace"]
143 go_into_dir (list) e.g., ["l", "Right"]
144 quit (list) e.g., ["q", "Esc"]
145 delete (list) e.g., ["d"]
146 copy (list) e.g., ["y"]
147 paste (list) e.g., ["p"]
148 rename (list) e.g., ["r"]
149 create (list) e.g., ["n"]
150 create_directory (list) e.g., ["Shift+n"]
151 filter (list) e.g., ["f"]
152 toggle_marker (list) e.g., [" "]
153 info (list) e.g., ["i"]
154
155Use 'Shift+x' or 'Ctrl+x' as needed. " " means space bar.
156
157EXAMPLES:
158 borders = "split"
159
160 [display.layout]
161 main = 40
162
163 [theme.accent]
164 fg = "#00ff00"
165 bg = "default"
166"##;
167
168 println!("{}", help_text);
169}