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
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 titles (bool) Show pane titles at the top
86 separators (bool) Draw vertical lines between panes
87 parent (bool) Show the parent directory pane
88 preview (bool) Show the file preview pane
89 preview_underline (bool) Use underline for preview selection instead of a highlighted selection
90 preview_underline_color (bool) Use underline colors instead of selection colors
91 entry_padding (usize) Entry padding for all the panes
92 scroll_padding (usize) Scroll padding of the main pane
93
94[display.layout]
95 parent (u16) Width % of the parent pane
96 main (u16) Width % of the center pane
97 preview (u16) Width % of the preview pane
98
99[theme]
100 selection_icon (str) The cursor string (e.g., "> ")
101
102# Theme sections (Each supports "fg" and "bg" keys,)
103[theme.selection] Selection bar colors fg (str), bg (str)
104[theme.accent] Border/title accents fg (str), bg (str)
105[theme.entry] Standard entry colors fg (str), bg (str)
106[theme.directory] Directory entry colors fg (str), bg (str)
107[theme.separator] Vertical line colors fg (str), bg (str)
108[theme.parent] Parent pane text fg (str), bg (str)
109[theme.preview] Preview pane text fg (str), bg (str)
110[theme.path] Path bar colors fg (str), bg (str)
111[theme.underline] Underline colors fg (str), bg (str)
112[theme.widget] Dialog/widget settings:
113 position (str/list/table) "center", "top_left", "bottom_right", [38, 32], { x = 25, y = 60 }
114 size (str/list/table) "small", "medium", "large", [38, 32], { w = 38, h = 32 }
115[theme.widget.color] fg/bg for dialog/widgets fg (str), bg (str)
116[theme.widget.border] fg/bg for dialog borders fg (str), bg (str)
117
118
119[editor]
120 cmd (str) Command to open files (e.g., "nvim")
121
122[keys]
123 open_file (list) e.g., ["Enter"]
124 go_up (list) e.g., ["k", "Up"]
125 go_down (list) e.g., ["j", "Down"]
126 go_parent (list) e.g., ["h", "Left", "Backspace"]
127 go_into_dir (list) e.g., ["l", "Right"]
128 quit (list) e.g., ["q", "Esc"]
129 delete (list) e.g., ["d"]
130 copy (list) e.g., ["y"]
131 paste (list) e.g., ["p"]
132 rename (list) e.g., ["r"]
133 create (list) e.g., ["n"]
134 create_directory (list) e.g., ["Shift+n"]
135 filter (list) e.g., ["f"]
136 toggle_marker (list) e.g., [" "]
137
138Use 'Shift+x' or 'Ctrl+x' as needed. " " means space bar.
139
140EXAMPLES:
141 borders = "split"
142
143 [display.layout]
144 main = 40
145
146 [theme.accent]
147 fg = "#00ff00"
148 bg = "default"
149"##;
150
151 println!("{}", help_text);
152}