mal/
cli.rs

1use clap::Parser;
2use figlet_rs::FIGfont;
3#[derive(Debug, Parser)]
4#[command(name = "mal", version, about = "A TUI client for myanimelist.net", long_about = None)]
5struct Cli {
6    /// Show extra information about the tool
7    #[arg(short = 'i', long = "info", action = clap::ArgAction::SetTrue)]
8    info: bool,
9    /// Show configuration file structure and all available options
10    #[arg(short = 'c', long = "config", action = clap::ArgAction::SetTrue)]
11    config: bool,
12}
13
14pub fn handle_args() -> bool {
15    let cli = Cli::parse();
16
17    if cli.info {
18        print_info();
19        return true;
20    } else if cli.config {
21        print_config_structure();
22        return true;
23    }
24    false
25}
26
27fn print_info() {
28    let standard_font = FIGfont::standard().unwrap();
29    let figlet = standard_font.convert("mal-cli");
30    let fig_string = figlet.unwrap().to_string();
31    println!(
32        r#"
33{fig_string}
34
35FILES:
36    - OAuth2 tokens:       $HOME/.config/mal-cli/oauth2.yml
37    - Cache data:          $HOME/.cache/mal-cli/
38    - Configuration file:  $HOME/.config/mal-cli/config.yml
39
40NOTE:
41    - Use GPU-enhanced terminals, otherwise the images won't be rendered
42    - The configuration file is optional. If it does not exist, the application will create a default one.
43    - The cache directory is used to store images
44"#
45    );
46}
47
48fn print_config_structure() {
49    println!(
50        r#"
51
52CONFIGURATION KEYS:
53===================
54
55KEYBINDINGS:
56  keys:
57    help: '?'                    # Show help menu
58    back: 'q'                    # Go back/quit current view
59    search: '/'                  # Open search
60    toggle: 's'                  # Toggle between anime/manga or switch states
61    next_state: Ctrl+p           # Navigate to next state/page
62    open_popup: 'r'              # Open rating/status popup
63
64THEME COLORS:
65  theme:
66    mal_color: '#2E51A2'         # MyAnimeList brand color (blue)
67    active: Cyan                 # Color for active/focused elements
68    banner: LightCyan            # Color for banners and titles
69    hovered: Magenta             # Color for hovered elements
70    text: White                  # Default text color
71    selected: LightCyan          # Color for selected items
72    error_border: Red            # Border color for error dialogs
73    error_text: LightRed         # Text color for error messages
74    inactive: Gray               # Color for inactive/unfocused elements
75    status_completed: Green      # Color for completed anime/manga
76    status_dropped: Gray         # Color for dropped items
77    status_on_hold: Yellow       # Color for on-hold items
78    status_watching: Blue        # Color for currently watching/reading
79    status_plan_to_watch: Cyan   # Color for plan-to-watch/read items
80    status_other: White          # Color for other status types
81
82APPLICATION BEHAVIOR:
83  behavior:
84    tick_rate_milliseconds: 500  # UI refresh rate (lower = more responsive)
85    show_logger: false           # Show debug logger window
86
87CONTENT SETTINGS:
88  nsfw: false                    # Show NSFW (18+) content
89  title_language: English       # Preferred title language (English/Japanese)
90  manga_display_type: Both      # Show volumes, chapters, or both (Vol/Ch/Both)
91
92RANKING TYPES:
93  top_three_anime_types:         # Anime ranking types to show in top 3
94    - airing                     # Currently airing anime
95    - all                        # All-time rankings
96    - upcoming                   # Upcoming anime
97    - movie                      # Movie rankings
98    - special                    # Special episodes
99    - ova                        # Original Video Animation
100    - tv                         # TV series
101    - popularity                 # Most popular
102    - favorite                   # Most favorited
103
104  top_three_manga_types:         # Manga ranking types to show in top 3
105    - all                        # All-time rankings
106    - manga                      # Manga only
107    - novels                     # Light novels
108    - oneshots                   # One-shot manga
109    - doujinshi                  # Self-published works
110    - manhwa                     # Korean comics
111    - manhua                     # Chinese comics
112    - bypopularity               # Most popular
113    - favorite                   # Most favorited
114
115PERFORMANCE SETTINGS:
116  navigation_stack_limit: 15     # Max number of pages to keep in history
117  search_limit: 30               # Max search results per page
118  max_cached_images: 15          # Max images to cache for faster loading
119
120EXAMPLE CONFIG FILE:
121====================
122Copy the example configuration from: config.example.yml
123Location: $HOME/.config/mal-cli/config.yml
124"#
125    );
126}