Skip to content

Commit

Permalink
Add feature to get specific scheme information from current scheme (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamyGolden authored Oct 8, 2024
1 parent c3e02cc commit c7bbefc
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 39 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

### Added

- Support arguments with `current` subcommand to allow consumers to get
specific current scheme data

## [0.21.1] - 2024-10-02

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ The following is a table of the available subcommands for the CLI tool (Tinty),
| `list` | Lists all available themes. | Optional argument `--custom-schemes` to list saved custom theme files using `tinty generate-scheme` | `tinty list` |
| `apply` | Applies a specific theme. | `<scheme_system>-<scheme_name>`: Name of the system and scheme to apply. | `tinty apply base16-mocha` |
| `init` | Initializes the tool with the last applied theme otherwise `default-scheme` from `config.toml`. | - | `tinty init` |
| `current` | Displays the currently applied theme. | - | `tinty current` |
| `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` |
| `config` | Displays config related information currently in use by Tinty. Without flags it returns `config.yml` content. | - | `tinty config` |
| `info` | Provides information about themes. | `[<scheme_system>-<scheme_name>]`: Optional argument `--custom-schemes` to provide information on any custom schemes | `tinty info base16-mocha` |
| `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` |
Expand Down
2 changes: 1 addition & 1 deletion contrib/completion/tinty.bash
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ _tinty() {
return 0
;;
tinty__current)
opts="-c -d -h --config --data-dir --help"
opts="-c -d -h --config --data-dir --help author description name slug system variant"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down
4 changes: 2 additions & 2 deletions contrib/completion/tinty.elvish
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set edit:completion:arg-completer[tinty] = {|@words|
cand -V 'Print version'
cand --version 'Print version'
cand build 'Builds the target theme template'
cand current 'Prints the last scheme name applied'
cand current 'Prints the last scheme name applied or specific values from the current scheme'
cand generate-completion 'Generates a shell completion script'
cand generate-scheme 'Generates a scheme based on an image'
cand info 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)'
Expand Down Expand Up @@ -159,7 +159,7 @@ set edit:completion:arg-completer[tinty] = {|@words|
}
&'tinty;help'= {
cand build 'Builds the target theme template'
cand current 'Prints the last scheme name applied'
cand current 'Prints the last scheme name applied or specific values from the current scheme'
cand generate-completion 'Generates a shell completion script'
cand generate-scheme 'Generates a scheme based on an image'
cand info 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)'
Expand Down
35 changes: 22 additions & 13 deletions contrib/completion/tinty.fish
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ complete -c tinty -n "__fish_tinty_needs_command" -s d -l data-dir -d 'Optional
complete -c tinty -n "__fish_tinty_needs_command" -s h -l help -d 'Print help'
complete -c tinty -n "__fish_tinty_needs_command" -s V -l version -d 'Print version'
complete -c tinty -n "__fish_tinty_needs_command" -f -a "build" -d 'Builds the target theme template'
complete -c tinty -n "__fish_tinty_needs_command" -f -a "current" -d 'Prints the last scheme name applied'
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'
complete -c tinty -n "__fish_tinty_needs_command" -f -a "generate-completion" -d 'Generates a shell completion script'
complete -c tinty -n "__fish_tinty_needs_command" -f -a "generate-scheme" -d 'Generates a scheme based on an image'
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)'
Expand All @@ -39,6 +39,7 @@ complete -c tinty -n "__fish_tinty_needs_command" -f -a "config" -d 'Provides co
complete -c tinty -n "__fish_tinty_needs_command" -f -a "apply" -d 'Applies a theme based on the chosen scheme'
complete -c tinty -n "__fish_tinty_needs_command" -f -a "install" -d 'Install the environment needed for tinty'
complete -c tinty -n "__fish_tinty_needs_command" -f -a "update" -d 'Update to the latest themes'
complete -c tinty -n "__fish_tinty_needs_command" -f -a "sync" -d 'Install missing templates in tinty/config.toml and update existing templates'
complete -c tinty -n "__fish_tinty_needs_command" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c tinty -n "__fish_tinty_using_subcommand build" -s c -l config -d 'Optional path to the tinty config.toml file' -r
complete -c tinty -n "__fish_tinty_using_subcommand build" -s d -l data-dir -d 'Optional path to the tinty data directory' -r
Expand Down Expand Up @@ -78,22 +79,30 @@ complete -c tinty -n "__fish_tinty_using_subcommand config" -l data-dir-path -d
complete -c tinty -n "__fish_tinty_using_subcommand config" -s h -l help -d 'Print help'
complete -c tinty -n "__fish_tinty_using_subcommand apply" -s c -l config -d 'Optional path to the tinty config.toml file' -r
complete -c tinty -n "__fish_tinty_using_subcommand apply" -s d -l data-dir -d 'Optional path to the tinty data directory' -r
complete -c tinty -n "__fish_tinty_using_subcommand apply" -s q -l quiet -d 'Silence stdout'
complete -c tinty -n "__fish_tinty_using_subcommand apply" -s h -l help -d 'Print help'
complete -c tinty -n "__fish_tinty_using_subcommand install" -s c -l config -d 'Optional path to the tinty config.toml file' -r
complete -c tinty -n "__fish_tinty_using_subcommand install" -s d -l data-dir -d 'Optional path to the tinty data directory' -r
complete -c tinty -n "__fish_tinty_using_subcommand install" -s q -l quiet -d 'Silence stdout'
complete -c tinty -n "__fish_tinty_using_subcommand install" -s h -l help -d 'Print help'
complete -c tinty -n "__fish_tinty_using_subcommand update" -s c -l config -d 'Optional path to the tinty config.toml file' -r
complete -c tinty -n "__fish_tinty_using_subcommand update" -s d -l data-dir -d 'Optional path to the tinty data directory' -r
complete -c tinty -n "__fish_tinty_using_subcommand update" -s q -l quiet -d 'Silence stdout'
complete -c tinty -n "__fish_tinty_using_subcommand update" -s h -l help -d 'Print help'
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'
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'
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'
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'
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)'
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'
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'
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'
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'
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'
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'
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)'
complete -c tinty -n "__fish_tinty_using_subcommand sync" -s c -l config -d 'Optional path to the tinty config.toml file' -r
complete -c tinty -n "__fish_tinty_using_subcommand sync" -s d -l data-dir -d 'Optional path to the tinty data directory' -r
complete -c tinty -n "__fish_tinty_using_subcommand sync" -s q -l quiet -d 'Silence stdout'
complete -c tinty -n "__fish_tinty_using_subcommand sync" -s h -l help -d 'Print help'
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'
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'
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'
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'
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)'
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'
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'
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'
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'
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'
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'
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'
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)'
4 changes: 2 additions & 2 deletions contrib/completion/tinty.powershell
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Register-ArgumentCompleter -Native -CommandName 'tinty' -ScriptBlock {
[CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('build', 'build', [CompletionResultType]::ParameterValue, 'Builds the target theme template')
[CompletionResult]::new('current', 'current', [CompletionResultType]::ParameterValue, 'Prints the last scheme name applied')
[CompletionResult]::new('current', 'current', [CompletionResultType]::ParameterValue, 'Prints the last scheme name applied or specific values from the current scheme')
[CompletionResult]::new('generate-completion', 'generate-completion', [CompletionResultType]::ParameterValue, 'Generates a shell completion script')
[CompletionResult]::new('generate-scheme', 'generate-scheme', [CompletionResultType]::ParameterValue, 'Generates a scheme based on an image')
[CompletionResult]::new('info', 'info', [CompletionResultType]::ParameterValue, 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)')
Expand Down Expand Up @@ -175,7 +175,7 @@ Register-ArgumentCompleter -Native -CommandName 'tinty' -ScriptBlock {
}
'tinty;help' {
[CompletionResult]::new('build', 'build', [CompletionResultType]::ParameterValue, 'Builds the target theme template')
[CompletionResult]::new('current', 'current', [CompletionResultType]::ParameterValue, 'Prints the last scheme name applied')
[CompletionResult]::new('current', 'current', [CompletionResultType]::ParameterValue, 'Prints the last scheme name applied or specific values from the current scheme')
[CompletionResult]::new('generate-completion', 'generate-completion', [CompletionResultType]::ParameterValue, 'Generates a shell completion script')
[CompletionResult]::new('generate-scheme', 'generate-scheme', [CompletionResultType]::ParameterValue, 'Generates a scheme based on an image')
[CompletionResult]::new('info', 'info', [CompletionResultType]::ParameterValue, 'Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg: tinty info base16-mocha)')
Expand Down
5 changes: 3 additions & 2 deletions contrib/completion/tinty.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ _arguments "${_arguments_options[@]}" : \
'--data-dir=[Optional path to the tinty data directory]:DIRECTORY: ' \
'-h[Print help]' \
'--help[Print help]' \
'::property_name -- Optional field to retrieve scheme information for\: author, description, name, etc.:(author description name slug system variant)' \
&& ret=0
;;
(generate-completion)
Expand Down Expand Up @@ -256,7 +257,7 @@ esac
_tinty_commands() {
local commands; commands=(
'build:Builds the target theme template' \
'current:Prints the last scheme name applied' \
'current:Prints the last scheme name applied or specific values from the current scheme' \
'generate-completion:Generates a shell completion script' \
'generate-scheme:Generates a scheme based on an image' \
'info:Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg\: tinty info base16-mocha)' \
Expand Down Expand Up @@ -305,7 +306,7 @@ _tinty__generate-scheme_commands() {
_tinty__help_commands() {
local commands; commands=(
'build:Builds the target theme template' \
'current:Prints the last scheme name applied' \
'current:Prints the last scheme name applied or specific values from the current scheme' \
'generate-completion:Generates a shell completion script' \
'generate-scheme:Generates a scheme based on an image' \
'info:Shows scheme colors for all schemes matching <scheme_system>-<scheme_name> (Eg\: tinty info base16-mocha)' \
Expand Down
16 changes: 15 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,21 @@ pub fn build_cli() -> Command {

)
.subcommand(
Command::new("current").about("Prints the last scheme name applied")
Command::new("current")
.about("Prints the last scheme name applied or specific values from the current scheme")
.arg(
Arg::new("property_name")
.help("Optional field to retrieve scheme information for: author, description, name, etc.")
.value_parser([
PossibleValue::new("author"),
PossibleValue::new("description"),
PossibleValue::new("name"),
PossibleValue::new("slug"),
PossibleValue::new("system"),
PossibleValue::new("variant"),
])
.required(false)
)
)
.subcommand(
Command::new("generate-completion").about("Generates a shell completion script").arg(
Expand Down
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ fn main() -> Result<()> {
operations::build::build(&template_path, &schemes_repo_path)?;
}
}
Some(("current", _)) => {
operations::current::current(&data_path)?;
Some(("current", sub_matches)) => {
let property_name = sub_matches
.get_one::<String>("property_name")
.map(|s| s.as_str())
.unwrap_or_default();

operations::current::current(&data_path, property_name)?;
}
Some(("config", sub_matches)) => {
let data_dir_path_flag = sub_matches.get_flag("data-dir-path");
Expand Down
Loading

0 comments on commit c7bbefc

Please sign in to comment.