Skip to content
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
10 changes: 10 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ license = "MIT"

[dependencies]
clap = { version = "4.5.47", features = ["derive"] }
clap_complete = { version = "4.6.3" }
console = "0.16.1"
ctrlc = "3.5.0"
dirs = "6.0.0"
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [Custom quotes](#custom-quotes)
- [Usage](#usage)
- [Translation Modes](#translation-modes)
- [Autocompletion](#autocompletion)
- [Community Showcase](#community-showcase)
- [Contributing](#contributing)

Expand Down Expand Up @@ -241,6 +242,15 @@ Multiple modes can be combined by passing a comma-separated list: `--translation

Furigana displays readings aligned with their kanji, supporting both single-kanji annotations (`知(し)`) and compound words (`大海(たいかい)`). Only quotes that include inline ruby markup in their `japanese` field will show furigana readings. Use `--furigana-position above` (or `furigana_position = "above"` in config) to render readings above the Japanese text instead of below.

## Autocompletion

You can get the script by running this command:
```bash
kotofetch completion <SHELL>
```
The setup depends on the specific shell.

The supported shells are those supported by the currently used `clap_complete` version.

## Community Showcase

Expand Down
8 changes: 7 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use clap::{Args, Parser, Subcommand, ValueEnum};
use clap_complete::Shell;
use std::path::PathBuf;

#[derive(Parser, Debug)]
#[command(author, version, about)]
#[command(name = "kotofetch", author, version, about)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
Expand Down Expand Up @@ -87,6 +88,11 @@ pub enum Commands {
#[command(subcommand)]
source: InitSource,
},
/// Output the completion script
Completion {
/// Select the shell
shell: Shell,
},
}

#[derive(Subcommand, Debug)]
Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ mod display;
mod quotes;

use crate::cli::{Cli, Commands, InitSource};
use clap::Parser;
use clap::{CommandFactory, Parser};
use clap_complete::generate;
use std::io;

fn main() {
let cli = Cli::parse();
Expand All @@ -19,6 +21,11 @@ fn main() {
std::process::exit(1);
}
}
Some(Commands::Completion { shell }) => {
let mut cmd = Cli::command();
let cmdname = cmd.get_name().to_string();
generate(*shell, &mut cmd, cmdname, &mut io::stdout());
}
None => {
let user_cfg = config::load_user_config(cli.config.clone());
let runtime = config::make_runtime_config(user_cfg, &cli);
Expand Down