-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
218 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
# Unless | ||
|
||
[`Unless`] skips invokation if given [condition] succeeds. | ||
[`Unless`] skips invokation if given condition is `true`. | ||
|
||
```go | ||
carapace.ActionValues( | ||
"./local", | ||
"~/home", | ||
"/abs", | ||
"one", | ||
"two", | ||
"three", | ||
).Unless(condition.CompletingPath) | ||
carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action { | ||
switch len(c.Parts) { | ||
case 0: | ||
return carapace.ActionValues("true", "false").Suffix(":") | ||
default: | ||
return carapace.Batch( | ||
carapace.ActionValues( | ||
"yes", | ||
"positive", | ||
).Unless(c.Parts[0] != "true"), | ||
carapace.ActionValues( | ||
"no", | ||
"negative", | ||
).Unless(c.Parts[0] != "false"), | ||
).ToA() | ||
} | ||
}) | ||
``` | ||
|
||
![](./unless.cast) | ||
|
||
[`Unless`]:https://pkg.go.dev/github.com/carapace-sh/carapace#Action.Unless | ||
[condition]:https://pkg.go.dev/github.com/carapace-sh/carapace/pkg/condition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{"version": 2, "width": 80, "height": 12, "timestamp": 1726929444, "env": {"SHELL": "elvish", "TERM": "tmux-256color"}} | ||
[0.2044, "o", "\u001b[?7h\u001b[7m⏎\u001b[m \r \r\u001b[?7l\u001b[?2004h"] | ||
[0.20511, "o", "\u001b[?25l\r???> ???> \r\u001b[5C\u001b[?25h\u001b[?25l\r\u001b[5C\u001b[K\r\u001b[5C\u001b[?25h"] | ||
[0.223458, "o", "\u001b[?25l\r\r\u001b[5C\u001b[?25h\u001b[?25l\r\r\u001b[5C\u001b[?25h"] | ||
[0.22353, "o", "\u001b[?25l\r\u001b[K\u001b[0;1;36m~\u001b[0;m \r\n\u001b[0;1;37mesh\u001b[0;m \u001b[0;1;32m❯\u001b[0;m \r\u001b[6C\u001b[?25h"] | ||
[0.602139, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[6C\u001b[0;31me\u001b[0;m\r\u001b[7C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[7C\u001b[?25h"] | ||
[0.602641, "o", "\u001b[?25l\u001b[1A\r\r\n\r\u001b[7C\u001b[?25h"] | ||
[0.615016, "o", "\u001b[?25l\u001b[1A\r\r\n\r\u001b[7C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[7C\u001b[?25h"] | ||
[0.615168, "o", "\u001b[?25l\u001b[1A\r\r\n\r\u001b[7C\u001b[?25h"] | ||
[1.100985, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[7C\u001b[0;31mx\u001b[0;m\r\u001b[8C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[8C\u001b[?25h"] | ||
[1.218184, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[6C\u001b[K\u001b[0;32mexa\u001b[0;m\r\u001b[9C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[9C\u001b[?25h"] | ||
[1.33266, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[6C\u001b[K\u001b[0;31mexam\u001b[0;m\r\u001b[10C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[10C\u001b[?25h"] | ||
[1.397167, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[10C\u001b[0;31mp\u001b[0;m\r\u001b[11C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[11C\u001b[?25h"] | ||
[1.514046, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[11C\u001b[0;31ml\u001b[0;m\r\u001b[12C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[12C\u001b[?25h"] | ||
[1.628261, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[6C\u001b[K\u001b[0;32mexample\u001b[0;m\r\u001b[13C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[13C\u001b[?25h"] | ||
[1.729894, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[13C \r\u001b[14C\u001b[?25h"] | ||
[1.730018, "o", "\u001b[?25l\u001b[1A\r\r\n\r\u001b[14C\u001b[?25h"] | ||
[2.24433, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[14Cm\r\u001b[15C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[15C\u001b[?25h"] | ||
[2.301778, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[15Co\r\u001b[16C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[16C\u001b[?25h"] | ||
[2.428727, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[16Cdifier \r\u001b[23C\u001b[?25h"] | ||
[2.837409, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[23C-\r\u001b[24C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[24C\u001b[?25h"] | ||
[2.981529, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[24C-\r\u001b[25C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[25C\u001b[?25h"] | ||
[3.569226, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[23C\u001b[K\u001b[0;4m--batch \r\n\u001b[0;1;37;45m COMPLETING argument \u001b[0;m \r\n\u001b[0;7;34m--batch\u001b[0;2;7m (Batch()) \u001b[0;m --help\u001b[0;2m (help for modifier) \r\n\u001b[0;34m--cache\u001b[0;2m (Cache()) \u001b[0;m \u001b[0;34m--invoke\u001b[0;2m (Invoke()) \r\n\u001b[0;34m--cache-key\u001b[0;2m (Cache()) \u001b[0;m \u001b[0;34m--list\u001b[0;2m (List()) \r\n\u001b[0;34m--chdir\u001b[0;2m (Chdir()) \u001b[0;m \u001b[0;34m--multiparts\u001b[0;2m (MultiParts()) \r\n\u001b[0;34m--chdirf\u001b[0;2m (ChdirF()) \u001b[0;m \u001b[0;34m--multipartsp\u001b[0;2m (MultiPartsP()) \r\n\u001b[0;34m--filter\u001b[0;2m (Filter()) \u001b[0;m \u001b[0;34m--nospace\u001b[0;2m (NoSpace()) \r\n\u001b[0;34m--filterargs\u001b[0;2m (FilterArgs()) \u001b[0;m \u001b[0;33m--persistentFlag\u001b[0;2m (Help message for persistentFlag\r\n\u001b[0;34m--filterparts\u001b[0;2m (FilterParts())\u001b[0;m \u001b[0;34m--persistentFlag2\u001b[0;2m (Help message for persistentFla\r\n\u001b[0;7;35m \u001b[0;35m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0;m\u001b[9A\r\u001b[22C\u001b[?25h"] | ||
[3.632282, "o", "\u001b[?25l\u001b[2A\r\r\n\u001b[25C\u001b[K\u001b[0;4mmultiparts \r\n\u001b[22C\u001b[0;mu\r\n\u001b[2C\u001b[K\u001b[0;7;34mmultiparts\u001b[0;2;7m (MultiParts()) \u001b[0;m \u001b[0;34m--uniquelist\u001b[0;2m (UniqueList()) \r\n\u001b[2C\u001b[0;m\u001b[K\u001b[0;34mmultipartsp\u001b[0;2m (MultiPartsP())\u001b[0;m \u001b[0;34m--uniquelistf\u001b[0;2m (UniqueListF())\r\n\u001b[2C\u001b[0;m\u001b[K\u001b[0;34msuffix\u001b[0;2m (Suffix()) \u001b[0;m \u001b[0;34m--unless\u001b[0;2m (Unless()) \r\n\u001b[2C\u001b[0;m\u001b[K\u001b[0;34msuppress\u001b[0;2m (Suppress()) \u001b[0;m \u001b[0;34m--unlessf\u001b[0;2m (UnlessF()) \r\n\u001b[2C\u001b[0;m\u001b[K\u001b[0;34mtimeout\u001b[0;2m (Timeout()) \u001b[0;m \u001b[0;34m--usage\u001b[0;2m (Usage()) \u001b[0;m\r\n\u001b[J\u001b[A\u001b[5A\r\u001b[23C\u001b[?25h"] | ||
[4.33225, "o", "\u001b[?25l\u001b[2A\r\r\n\u001b[25C\u001b[K\u001b[0;4muniquelist \r\n\u001b[23C\u001b[0;mn\r\n\u001b[2C\u001b[K\u001b[0;7;34muniquelist\u001b[0;2;7m (UniqueList()) \u001b[0;m \u001b[0;34m--unless\u001b[0;2m (Unless()) \r\n\u001b[2C\u001b[0;m\u001b[K\u001b[0;34muniquelistf\u001b[0;2m (UniqueListF())\u001b[0;m \u001b[0;34m--unlessf\u001b[0;2m (UnlessF())\u001b[0;m\r\n\u001b[J\u001b[A\u001b[2A\r\u001b[24C\u001b[?25h"] | ||
[4.33239, "o", "\u001b[?25l\u001b[2A\r\r\n\r\n\r\n\r\n\u001b[2A\r\u001b[24C\u001b[?25h"] | ||
[4.466069, "o", "\u001b[?25l\u001b[2A\r\r\n\u001b[27C\u001b[K\u001b[0;4mless \r\n\u001b[24C\u001b[0;ml\r\n\u001b[4C\u001b[K\u001b[0;7;34mless\u001b[0;2;7m (Unless())\u001b[0;m \u001b[0;34m--unlessf\u001b[0;2m (UnlessF())\u001b[0;m\r\n\u001b[J\u001b[A\u001b[1A\r\u001b[25C\u001b[?25h"] | ||
[4.466185, "o", "\u001b[?25l\u001b[2A\r\r\n\r\n\r\n\u001b[1A\r\u001b[25C\u001b[?25h"] | ||
[5.108758, "o", "\u001b[?25l\u001b[2A\r\r\n\u001b[31C\u001b[K\u001b[0;4mf \r\n\r\n\u001b[0;m\u001b[K\u001b[0;34m--unless\u001b[0;2m (Unless())\u001b[0;m \u001b[0;7;34m--unlessf\u001b[0;2;7m (UnlessF())\u001b[0;m\u001b[1A\r\u001b[25C\u001b[?25h"] | ||
[5.530079, "o", "\u001b[?25l\u001b[2A\r\r\n\u001b[23C\u001b[K--unlessf \r\n\u001b[J\u001b[A\r\u001b[33C\u001b[?25h"] | ||
[5.530333, "o", "\u001b[?25l\u001b[1A\r\r\n\r\u001b[33C\u001b[?25h"] | ||
[5.948117, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[33C\u001b[0;4m./local \r\n\u001b[0;1;37;45m COMPLETING argument \u001b[0;m \r\n\u001b[0;7m./local\u001b[0;m /abs one three two ~/home\u001b[1A\r\u001b[22C\u001b[?25h"] | ||
[5.948485, "o", "\u001b[?25l\u001b[2A\r\r\n\r\n\r\n\u001b[1A\r\u001b[22C\u001b[?25h"] | ||
[5.948949, "o", "\u001b[?25l\u001b[2A\r\r\n\r\n\r\n\u001b[1A\r\u001b[22C\u001b[?25h"] | ||
[5.949151, "o", "\u001b[?25l\u001b[2A\r\r\n\r\n\r\n\u001b[1A\r\u001b[22C\u001b[?25h"] | ||
[7.585602, "o", "\u001b[?25l\u001b[2A\r\r\n\u001b[33C\u001b[K\r\n\u001b[J\u001b[A\r\u001b[33C\u001b[?25h"] | ||
[8.093878, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[33C/\r\u001b[34C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[34C\u001b[?25h"] | ||
[8.279985, "o", "\u001b[?25l\u001b[1A\r\u001b[0;2musage: \u001b[0;mUnlessF()\u001b[K\r\n\u001b[0;31merror:\u001b[0;m no candidates\u001b[K\r\n\u001b[K\u001b[0;1;36m~\u001b[0;m \r\n\u001b[0;1;37mesh\u001b[0;m \u001b[0;1;32m❯\u001b[0;m \u001b[0;32mexample\u001b[0;m modifier --unlessf /\r\u001b[34C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[34C\u001b[?25h"] | ||
[8.938739, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[33C\u001b[K\r\u001b[33C\u001b[?25h"] | ||
[9.277511, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[33C~\r\u001b[34C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[34C\u001b[?25h"] | ||
[9.596644, "o", "\u001b[?25l\u001b[1A\r\u001b[0;2musage: \u001b[0;mUnlessF()\u001b[K\r\n\u001b[0;31merror:\u001b[0;m no candidates\u001b[K\r\n\u001b[K\u001b[0;1;36m~\u001b[0;m \r\n\u001b[0;1;37mesh\u001b[0;m \u001b[0;1;32m❯\u001b[0;m \u001b[0;32mexample\u001b[0;m modifier --unlessf ~\r\u001b[34C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[34C\u001b[?25h"] | ||
[10.345352, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[33C\u001b[K\r\u001b[33C\u001b[?25h"] | ||
[10.58072, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[33C.\r\u001b[34C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[34C\u001b[?25h"] | ||
[10.648674, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[34C/\r\u001b[35C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[35C\u001b[?25h"] | ||
[10.777515, "o", "\u001b[?25l\u001b[1A\r\u001b[0;2musage: \u001b[0;mUnlessF()\u001b[K\r\n\u001b[0;31merror:\u001b[0;m no candidates\u001b[K\r\n\u001b[K\u001b[0;1;36m~\u001b[0;m \r\n\u001b[0;1;37mesh\u001b[0;m \u001b[0;1;32m❯\u001b[0;m \u001b[0;32mexample\u001b[0;m modifier --unlessf ./\r\u001b[35C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[35C\u001b[?25h"] | ||
[11.741015, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[34C\u001b[K\r\u001b[34C\u001b[?25h"] | ||
[12.268904, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[33C\u001b[K\r\u001b[33C\u001b[?25h"] | ||
[12.359171, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[33Ct\r\u001b[34C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[34C\u001b[?25h"] | ||
[12.522386, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[33C\u001b[K\u001b[0;4mthree \r\n\u001b[0;1;37;45m COMPLETING argument \u001b[0;m \r\n\u001b[0;7mthree\u001b[0;m two\u001b[1A\r\u001b[22C\u001b[?25h"] | ||
[13.289741, "o", "\u001b[?25l\u001b[2A\r\r\n\u001b[34C\u001b[K\u001b[0;4mwo \r\n\r\n\u001b[0;m\u001b[Kthree \u001b[0;7mtwo\u001b[0;m\u001b[1A\r\u001b[22C\u001b[?25h"] | ||
[13.78906, "o", "\u001b[?25l\u001b[2A\r\r\n\u001b[33C\u001b[Ktwo \r\n\u001b[J\u001b[A\r\u001b[37C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[37C\u001b[?25h"] | ||
[15.213421, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[6C\u001b[K\r\u001b[6C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[6C\u001b[?25h"] | ||
[15.215373, "o", "\u001b[?25l\u001b[1A\r\r\n\r\u001b[6C\u001b[?25h"] | ||
[15.246035, "o", "\u001b[?25l\u001b[1A\r\r\n\r\u001b[6C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[6C\u001b[?25h"] | ||
[15.644121, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[6C\u001b[0;31me\u001b[0;m\r\u001b[7C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[7C\u001b[?25h"] | ||
[15.85989, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[7C\u001b[0;31mx\u001b[0;m\r\u001b[8C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[8C\u001b[?25h"] | ||
[16.050456, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[8C\u001b[0;31mi\u001b[0;m\r\u001b[9C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[9C\u001b[?25h"] | ||
[16.115359, "o", "\u001b[?25l\u001b[1A\r\r\n\u001b[6C\u001b[K\u001b[0;32mexit\u001b[0;m\r\u001b[10C\u001b[?25h\u001b[?25l\u001b[1A\r\r\n\r\u001b[10C\u001b[?25h"] | ||
[16.339424, "o", "\u001b[?25l\u001b[1A\r\r\n\r\n\r\u001b[?25h\u001b[?7h\u001b[?2004l\r"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# UnlessF | ||
|
||
[`UnlessF`] skips invokation if given [condition] returns `true`. | ||
|
||
```go | ||
carapace.ActionValues( | ||
"./local", | ||
"~/home", | ||
"/abs", | ||
"one", | ||
"two", | ||
"three", | ||
).UnlessF(condition.CompletingPath) | ||
``` | ||
|
||
![](./unlessF.cast) | ||
|
||
[`UnlessF`]:https://pkg.go.dev/github.com/carapace-sh/carapace#Action.UnlessF | ||
[condition]:https://pkg.go.dev/github.com/carapace-sh/carapace/pkg/condition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters