Skip to content

Commit c7bbefc

Browse files
authored
Add feature to get specific scheme information from current scheme (#72)
1 parent c3e02cc commit c7bbefc

File tree

12 files changed

+249
-39
lines changed

12 files changed

+249
-39
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Added
6+
7+
- Support arguments with `current` subcommand to allow consumers to get
8+
specific current scheme data
9+
310
## [0.21.1] - 2024-10-02
411

512
### Fixed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ The following is a table of the available subcommands for the CLI tool (Tinty),
164164
| `list` | Lists all available themes. | Optional argument `--custom-schemes` to list saved custom theme files using `tinty generate-scheme` | `tinty list` |
165165
| `apply` | Applies a specific theme. | `<scheme_system>-<scheme_name>`: Name of the system and scheme to apply. | `tinty apply base16-mocha` |
166166
| `init` | Initializes the tool with the last applied theme otherwise `default-scheme` from `config.toml`. | - | `tinty init` |
167-
| `current` | Displays the currently applied theme. | - | `tinty current` |
167+
| `current` | Displays the currently applied theme or current theme values. | `<scheme_property_name>` (Optional argument with the following supported values: `author` \| `description` \| `name` \| `slug` \| `system` \| `variant`) | `tinty current` |
168168
| `config` | Displays config related information currently in use by Tinty. Without flags it returns `config.yml` content. | - | `tinty config` |
169169
| `info` | Provides information about themes. | `[<scheme_system>-<scheme_name>]`: Optional argument `--custom-schemes` to provide information on any custom schemes | `tinty info base16-mocha` |
170170
| `build` | Builds the provided base16 or base24 template using [tinted-builder-rust]. | `<DIR>`: Path to the base16 or base24 template directory. | `tinty build path/to/tinted-tmux` |

contrib/completion/tinty.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ _tinty() {
217217
return 0
218218
;;
219219
tinty__current)
220-
opts="-c -d -h --config --data-dir --help"
220+
opts="-c -d -h --config --data-dir --help author description name slug system variant"
221221
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
222222
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
223223
return 0

contrib/completion/tinty.elvish

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set edit:completion:arg-completer[tinty] = {|@words|
2727
cand -V 'Print version'
2828
cand --version 'Print version'
2929
cand build 'Builds the target theme template'
30-
cand current 'Prints the last scheme name applied'
30+
cand current 'Prints the last scheme name applied or specific values from the current scheme'
3131
cand generate-completion 'Generates a shell completion script'
3232
cand generate-scheme 'Generates a scheme based on an image'
3333
cand info 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)'
@@ -159,7 +159,7 @@ set edit:completion:arg-completer[tinty] = {|@words|
159159
}
160160
&'tinty;help'= {
161161
cand build 'Builds the target theme template'
162-
cand current 'Prints the last scheme name applied'
162+
cand current 'Prints the last scheme name applied or specific values from the current scheme'
163163
cand generate-completion 'Generates a shell completion script'
164164
cand generate-scheme 'Generates a scheme based on an image'
165165
cand info 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)'

contrib/completion/tinty.fish

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ complete -c tinty -n "__fish_tinty_needs_command" -s d -l data-dir -d 'Optional
2929
complete -c tinty -n "__fish_tinty_needs_command" -s h -l help -d 'Print help'
3030
complete -c tinty -n "__fish_tinty_needs_command" -s V -l version -d 'Print version'
3131
complete -c tinty -n "__fish_tinty_needs_command" -f -a "build" -d 'Builds the target theme template'
32-
complete -c tinty -n "__fish_tinty_needs_command" -f -a "current" -d 'Prints the last scheme name applied'
32+
complete -c tinty -n "__fish_tinty_needs_command" -f -a "current" -d 'Prints the last scheme name applied or specific values from the current scheme'
3333
complete -c tinty -n "__fish_tinty_needs_command" -f -a "generate-completion" -d 'Generates a shell completion script'
3434
complete -c tinty -n "__fish_tinty_needs_command" -f -a "generate-scheme" -d 'Generates a scheme based on an image'
3535
complete -c tinty -n "__fish_tinty_needs_command" -f -a "info" -d 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)'
@@ -39,6 +39,7 @@ complete -c tinty -n "__fish_tinty_needs_command" -f -a "config" -d 'Provides co
3939
complete -c tinty -n "__fish_tinty_needs_command" -f -a "apply" -d 'Applies a theme based on the chosen scheme'
4040
complete -c tinty -n "__fish_tinty_needs_command" -f -a "install" -d 'Install the environment needed for tinty'
4141
complete -c tinty -n "__fish_tinty_needs_command" -f -a "update" -d 'Update to the latest themes'
42+
complete -c tinty -n "__fish_tinty_needs_command" -f -a "sync" -d 'Install missing templates in tinty/config.toml and update existing templates'
4243
complete -c tinty -n "__fish_tinty_needs_command" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
4344
complete -c tinty -n "__fish_tinty_using_subcommand build" -s c -l config -d 'Optional path to the tinty config.toml file' -r
4445
complete -c tinty -n "__fish_tinty_using_subcommand build" -s d -l data-dir -d 'Optional path to the tinty data directory' -r
@@ -78,22 +79,30 @@ complete -c tinty -n "__fish_tinty_using_subcommand config" -l data-dir-path -d
7879
complete -c tinty -n "__fish_tinty_using_subcommand config" -s h -l help -d 'Print help'
7980
complete -c tinty -n "__fish_tinty_using_subcommand apply" -s c -l config -d 'Optional path to the tinty config.toml file' -r
8081
complete -c tinty -n "__fish_tinty_using_subcommand apply" -s d -l data-dir -d 'Optional path to the tinty data directory' -r
82+
complete -c tinty -n "__fish_tinty_using_subcommand apply" -s q -l quiet -d 'Silence stdout'
8183
complete -c tinty -n "__fish_tinty_using_subcommand apply" -s h -l help -d 'Print help'
8284
complete -c tinty -n "__fish_tinty_using_subcommand install" -s c -l config -d 'Optional path to the tinty config.toml file' -r
8385
complete -c tinty -n "__fish_tinty_using_subcommand install" -s d -l data-dir -d 'Optional path to the tinty data directory' -r
86+
complete -c tinty -n "__fish_tinty_using_subcommand install" -s q -l quiet -d 'Silence stdout'
8487
complete -c tinty -n "__fish_tinty_using_subcommand install" -s h -l help -d 'Print help'
8588
complete -c tinty -n "__fish_tinty_using_subcommand update" -s c -l config -d 'Optional path to the tinty config.toml file' -r
8689
complete -c tinty -n "__fish_tinty_using_subcommand update" -s d -l data-dir -d 'Optional path to the tinty data directory' -r
90+
complete -c tinty -n "__fish_tinty_using_subcommand update" -s q -l quiet -d 'Silence stdout'
8791
complete -c tinty -n "__fish_tinty_using_subcommand update" -s h -l help -d 'Print help'
88-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "build" -d 'Builds the target theme template'
89-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "current" -d 'Prints the last scheme name applied'
90-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "generate-completion" -d 'Generates a shell completion script'
91-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "generate-scheme" -d 'Generates a scheme based on an image'
92-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "info" -d 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)'
93-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "init" -d 'Initializes with the exising config. Used to Initialize exising theme for when your shell starts up'
94-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "list" -d 'Lists available schemes'
95-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "config" -d 'Provides config related information'
96-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "apply" -d 'Applies a theme based on the chosen scheme'
97-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "install" -d 'Install the environment needed for tinty'
98-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "update" -d 'Update to the latest themes'
99-
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
92+
complete -c tinty -n "__fish_tinty_using_subcommand sync" -s c -l config -d 'Optional path to the tinty config.toml file' -r
93+
complete -c tinty -n "__fish_tinty_using_subcommand sync" -s d -l data-dir -d 'Optional path to the tinty data directory' -r
94+
complete -c tinty -n "__fish_tinty_using_subcommand sync" -s q -l quiet -d 'Silence stdout'
95+
complete -c tinty -n "__fish_tinty_using_subcommand sync" -s h -l help -d 'Print help'
96+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "build" -d 'Builds the target theme template'
97+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "current" -d 'Prints the last scheme name applied or specific values from the current scheme'
98+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "generate-completion" -d 'Generates a shell completion script'
99+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "generate-scheme" -d 'Generates a scheme based on an image'
100+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "info" -d 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)'
101+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "init" -d 'Initializes with the exising config. Used to Initialize exising theme for when your shell starts up'
102+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "list" -d 'Lists available schemes'
103+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "config" -d 'Provides config related information'
104+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "apply" -d 'Applies a theme based on the chosen scheme'
105+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "install" -d 'Install the environment needed for tinty'
106+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "update" -d 'Update to the latest themes'
107+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "sync" -d 'Install missing templates in tinty/config.toml and update existing templates'
108+
complete -c tinty -n "__fish_tinty_using_subcommand help; and not __fish_seen_subcommand_from build current generate-completion generate-scheme info init list config apply install update sync help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'

contrib/completion/tinty.powershell

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Register-ArgumentCompleter -Native -CommandName 'tinty' -ScriptBlock {
3030
[CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version')
3131
[CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version')
3232
[CompletionResult]::new('build', 'build', [CompletionResultType]::ParameterValue, 'Builds the target theme template')
33-
[CompletionResult]::new('current', 'current', [CompletionResultType]::ParameterValue, 'Prints the last scheme name applied')
33+
[CompletionResult]::new('current', 'current', [CompletionResultType]::ParameterValue, 'Prints the last scheme name applied or specific values from the current scheme')
3434
[CompletionResult]::new('generate-completion', 'generate-completion', [CompletionResultType]::ParameterValue, 'Generates a shell completion script')
3535
[CompletionResult]::new('generate-scheme', 'generate-scheme', [CompletionResultType]::ParameterValue, 'Generates a scheme based on an image')
3636
[CompletionResult]::new('info', 'info', [CompletionResultType]::ParameterValue, 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)')
@@ -175,7 +175,7 @@ Register-ArgumentCompleter -Native -CommandName 'tinty' -ScriptBlock {
175175
}
176176
'tinty;help' {
177177
[CompletionResult]::new('build', 'build', [CompletionResultType]::ParameterValue, 'Builds the target theme template')
178-
[CompletionResult]::new('current', 'current', [CompletionResultType]::ParameterValue, 'Prints the last scheme name applied')
178+
[CompletionResult]::new('current', 'current', [CompletionResultType]::ParameterValue, 'Prints the last scheme name applied or specific values from the current scheme')
179179
[CompletionResult]::new('generate-completion', 'generate-completion', [CompletionResultType]::ParameterValue, 'Generates a shell completion script')
180180
[CompletionResult]::new('generate-scheme', 'generate-scheme', [CompletionResultType]::ParameterValue, 'Generates a scheme based on an image')
181181
[CompletionResult]::new('info', 'info', [CompletionResultType]::ParameterValue, 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)')

contrib/completion/tinty.zsh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ _arguments "${_arguments_options[@]}" : \
5353
'--data-dir=[Optional path to the tinty data directory]:DIRECTORY: ' \
5454
'-h[Print help]' \
5555
'--help[Print help]' \
56+
'::property_name -- Optional field to retrieve scheme information for\: author, description, name, etc.:(author description name slug system variant)' \
5657
&& ret=0
5758
;;
5859
(generate-completion)
@@ -256,7 +257,7 @@ esac
256257
_tinty_commands() {
257258
local commands; commands=(
258259
'build:Builds the target theme template' \
259-
'current:Prints the last scheme name applied' \
260+
'current:Prints the last scheme name applied or specific values from the current scheme' \
260261
'generate-completion:Generates a shell completion script' \
261262
'generate-scheme:Generates a scheme based on an image' \
262263
'info:Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg\: tinty info base16-mocha)' \
@@ -305,7 +306,7 @@ _tinty__generate-scheme_commands() {
305306
_tinty__help_commands() {
306307
local commands; commands=(
307308
'build:Builds the target theme template' \
308-
'current:Prints the last scheme name applied' \
309+
'current:Prints the last scheme name applied or specific values from the current scheme' \
309310
'generate-completion:Generates a shell completion script' \
310311
'generate-scheme:Generates a scheme based on an image' \
311312
'info:Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg\: tinty info base16-mocha)' \

src/cli.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,21 @@ pub fn build_cli() -> Command {
4848

4949
)
5050
.subcommand(
51-
Command::new("current").about("Prints the last scheme name applied")
51+
Command::new("current")
52+
.about("Prints the last scheme name applied or specific values from the current scheme")
53+
.arg(
54+
Arg::new("property_name")
55+
.help("Optional field to retrieve scheme information for: author, description, name, etc.")
56+
.value_parser([
57+
PossibleValue::new("author"),
58+
PossibleValue::new("description"),
59+
PossibleValue::new("name"),
60+
PossibleValue::new("slug"),
61+
PossibleValue::new("system"),
62+
PossibleValue::new("variant"),
63+
])
64+
.required(false)
65+
)
5266
)
5367
.subcommand(
5468
Command::new("generate-completion").about("Generates a shell completion script").arg(

src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,13 @@ fn main() -> Result<()> {
7575
operations::build::build(&template_path, &schemes_repo_path)?;
7676
}
7777
}
78-
Some(("current", _)) => {
79-
operations::current::current(&data_path)?;
78+
Some(("current", sub_matches)) => {
79+
let property_name = sub_matches
80+
.get_one::<String>("property_name")
81+
.map(|s| s.as_str())
82+
.unwrap_or_default();
83+
84+
operations::current::current(&data_path, property_name)?;
8085
}
8186
Some(("config", sub_matches)) => {
8287
let data_dir_path_flag = sub_matches.get_flag("data-dir-path");

0 commit comments

Comments
 (0)