diff options
author | CosmicHorror <CosmicHorrorDev@pm.me> | 2023-11-02 18:05:55 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-02 19:05:55 -0500 |
commit | 4f77cfe1b8681bd164ea990e6c0ec2c2b8acb614 (patch) | |
tree | cc6a21cf2faec0665882c421d077863809c711b6 /gen | |
parent | 79f5de0db76aef3ab8f02d204890de6f74d69d12 (diff) |
Rework the replacements flag (#267)
* Add replacements tests
* Honor `-n` when using `--preview`
* Rework CLI for replacements flag
* Remove dead code
* Remove lingering TODO
Diffstat (limited to 'gen')
-rw-r--r-- | gen/completions/_sd | 3 | ||||
-rw-r--r-- | gen/completions/_sd.ps1 | 3 | ||||
-rw-r--r-- | gen/completions/sd.bash | 6 | ||||
-rw-r--r-- | gen/completions/sd.elv | 3 | ||||
-rw-r--r-- | gen/completions/sd.fish | 2 | ||||
-rw-r--r-- | gen/sd.1 | 6 |
6 files changed, 15 insertions, 8 deletions
diff --git a/gen/completions/_sd b/gen/completions/_sd index e8f2804..1a8c150 100644 --- a/gen/completions/_sd +++ b/gen/completions/_sd @@ -15,7 +15,8 @@ _sd() { local context curcontext="$curcontext" state line _arguments "${_arguments_options[@]}" \ -'-n+[Limit the number of replacements]:REPLACEMENTS: ' \ +'-n+[Limit the number of replacements that can occur per file. 0 indicates unlimited replacements]:LIMIT: ' \ +'--max-replacements=[Limit the number of replacements that can occur per file. 0 indicates unlimited replacements]:LIMIT: ' \ '-f+[Regex flags. May be combined (like \`-f mc\`).]:FLAGS: ' \ '--flags=[Regex flags. May be combined (like \`-f mc\`).]:FLAGS: ' \ '-p[Display changes in a human reviewable format (the specifics of the format are likely to change in the future)]' \ diff --git a/gen/completions/_sd.ps1 b/gen/completions/_sd.ps1 index 4704172..4ac2dfb 100644 --- a/gen/completions/_sd.ps1 +++ b/gen/completions/_sd.ps1 @@ -21,7 +21,8 @@ Register-ArgumentCompleter -Native -CommandName 'sd' -ScriptBlock { $completions = @(switch ($command) { 'sd' { - [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Limit the number of replacements') + [CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Limit the number of replacements that can occur per file. 0 indicates unlimited replacements') + [CompletionResult]::new('--max-replacements', 'max-replacements', [CompletionResultType]::ParameterName, 'Limit the number of replacements that can occur per file. 0 indicates unlimited replacements') [CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'Regex flags. May be combined (like `-f mc`).') [CompletionResult]::new('--flags', 'flags', [CompletionResultType]::ParameterName, 'Regex flags. May be combined (like `-f mc`).') [CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Display changes in a human reviewable format (the specifics of the format are likely to change in the future)') diff --git a/gen/completions/sd.bash b/gen/completions/sd.bash index 78eae05..b3e8b71 100644 --- a/gen/completions/sd.bash +++ b/gen/completions/sd.bash @@ -19,12 +19,16 @@ _sd() { case "${cmd}" in sd) - opts="-p -F -n -f -h -V --preview --fixed-strings --flags --help --version <FIND> <REPLACE_WITH> [FILES]..." + opts="-p -F -n -f -h -V --preview --fixed-strings --max-replacements --flags --help --version <FIND> <REPLACE_WITH> [FILES]..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in + --max-replacements) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; -n) COMPREPLY=($(compgen -f "${cur}")) return 0 diff --git a/gen/completions/sd.elv b/gen/completions/sd.elv index e455cc0..d737837 100644 --- a/gen/completions/sd.elv +++ b/gen/completions/sd.elv @@ -18,7 +18,8 @@ set edit:completion:arg-completer[sd] = {|@words| } var completions = [ &'sd'= { - cand -n 'Limit the number of replacements' + cand -n 'Limit the number of replacements that can occur per file. 0 indicates unlimited replacements' + cand --max-replacements 'Limit the number of replacements that can occur per file. 0 indicates unlimited replacements' cand -f 'Regex flags. May be combined (like `-f mc`).' cand --flags 'Regex flags. May be combined (like `-f mc`).' cand -p 'Display changes in a human reviewable format (the specifics of the format are likely to change in the future)' diff --git a/gen/completions/sd.fish b/gen/completions/sd.fish index a0e03ab..7d324ff 100644 --- a/gen/completions/sd.fish +++ b/gen/completions/sd.fish @@ -1,4 +1,4 @@ -complete -c sd -s n -d 'Limit the number of replacements' -r +complete -c sd -s n -l max-replacements -d 'Limit the number of replacements that can occur per file. 0 indicates unlimited replacements' -r complete -c sd -s f -l flags -d 'Regex flags. May be combined (like `-f mc`).' -r complete -c sd -s p -l preview -d 'Display changes in a human reviewable format (the specifics of the format are likely to change in the future)' complete -c sd -s F -l fixed-strings -d 'Treat FIND and REPLACE_WITH args as literal strings' @@ -8,7 +8,7 @@ sd .ie \n(.g .ds Aq \(aq .el .ds Aq ' .SH SYNOPSIS -\fBsd\fR [\fB\-p\fR|\fB\-\-preview\fR] [\fB\-F\fR|\fB\-\-fixed\-strings\fR] [\fB\-n \fR] [\fB\-f\fR|\fB\-\-flags\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] <\fIFIND\fR> <\fIREPLACE_WITH\fR> [\fIFILES\fR] +\fBsd\fR [\fB\-p\fR|\fB\-\-preview\fR] [\fB\-F\fR|\fB\-\-fixed\-strings\fR] [\fB\-n\fR|\fB\-\-max\-replacements\fR] [\fB\-f\fR|\fB\-\-flags\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] <\fIFIND\fR> <\fIREPLACE_WITH\fR> [\fIFILES\fR] .ie \n(.g .ds Aq \(aq .el .ds Aq ' .SH DESCRIPTION @@ -22,8 +22,8 @@ Display changes in a human reviewable format (the specifics of the format are li \fB\-F\fR, \fB\-\-fixed\-strings\fR Treat FIND and REPLACE_WITH args as literal strings .TP -\fB\-n\fR=\fIREPLACEMENTS\fR -Limit the number of replacements +\fB\-n\fR, \fB\-\-max\-replacements\fR=\fILIMIT\fR [default: 0] +Limit the number of replacements that can occur per file. 0 indicates unlimited replacements .TP \fB\-f\fR, \fB\-\-flags\fR=\fIFLAGS\fR Regex flags. May be combined (like `\-f mc`). |