diff --git a/command-signatures/json/ansible-playbook.json b/command-signatures/json/ansible-playbook.json index d77abba0..de2b9f9f 100644 --- a/command-signatures/json/ansible-playbook.json +++ b/command-signatures/json/ansible-playbook.json @@ -5,7 +5,8 @@ "name": "playbook", "description": "Playbook(s)", "isVariadic": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" }, "options": [ { diff --git a/command-signatures/json/apt.json b/command-signatures/json/apt.json index ad3af09c..68c29e7e 100644 --- a/command-signatures/json/apt.json +++ b/command-signatures/json/apt.json @@ -9,12 +9,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] } ] }, @@ -43,12 +47,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -77,12 +85,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -100,7 +112,8 @@ "name": "package", "description": "The package you want to install", "isVariadic": true, - "template": "filepaths" + "template": "filepaths", + "generatorName": "list_prefix" }, "options": [ { @@ -117,12 +130,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -157,12 +174,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -186,12 +207,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -222,12 +247,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -248,12 +277,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -289,12 +322,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] } ] }, @@ -304,7 +341,8 @@ "args": { "name": "package", "description": "The package you want to show", - "template": "filepaths" + "template": "filepaths", + "generatorName": "list_prefix" } }, { @@ -314,7 +352,8 @@ "name": "package", "description": "The package you want to satisfy", "isVariadic": true, - "template": "filepaths" + "template": "filepaths", + "generatorName": "list_prefix" }, "options": [ { @@ -331,12 +370,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -354,12 +397,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -377,12 +424,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] } ] }, @@ -393,7 +444,8 @@ "name": "package", "description": "The package you want to get source files for", "isVariadic": true, - "template": "filepaths" + "template": "filepaths", + "generatorName": "list_prefix" }, "options": [ { @@ -410,12 +462,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -428,7 +484,9 @@ "name": "--compile", "description": "Compile the package to a binary using dpkg-buildpackage" }, - { "name": "--only-source" }, + { + "name": "--only-source" + }, { "name": "--host-architecture", "description": "The architecture to build for", @@ -445,7 +503,8 @@ "args": { "name": "package", "description": "The package you want to build dependencies for", - "template": "filepaths" + "template": "filepaths", + "generatorName": "list_prefix" }, "options": [ { @@ -462,12 +521,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -484,7 +547,9 @@ "description": "The architecture to build for" } }, - { "name": "--only-source" } + { + "name": "--only-source" + } ] }, { @@ -493,7 +558,8 @@ "args": { "name": "package", "description": "The package you want to download", - "template": "filepaths" + "template": "filepaths", + "generatorName": "list_prefix" }, "options": [ { @@ -510,12 +576,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] } ] }, @@ -540,12 +610,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] }, { "name": [ @@ -563,7 +637,8 @@ "name": "package", "description": "The package you want to show the changelog for", "template": "filepaths", - "isVariadic": true + "isVariadic": true, + "generatorName": "list_prefix" }, "options": [ { @@ -580,12 +655,16 @@ { "name": "-y", "description": "Assume yes to all prompts", - "exclusiveOn": ["--assume-no"] + "exclusiveOn": [ + "--assume-no" + ] }, { "name": "--assume-no", "description": "Assume no to all prompts", - "exclusiveOn": ["-y"] + "exclusiveOn": [ + "-y" + ] } ] } diff --git a/command-signatures/json/brew.json b/command-signatures/json/brew.json index a176cdc9..c22cc161 100644 --- a/command-signatures/json/brew.json +++ b/command-signatures/json/brew.json @@ -287,7 +287,8 @@ "--analytics" ], "args": { - "template": "filepaths" + "template": "filepaths", + "generatorName": "gist_logs_actions" } }, { @@ -388,7 +389,8 @@ "--analytics" ], "args": { - "template": "filepaths" + "template": "filepaths", + "generatorName": "gist_logs_actions" } }, { diff --git a/command-signatures/json/bun.json b/command-signatures/json/bun.json index 90091356..e69ec2ea 100644 --- a/command-signatures/json/bun.json +++ b/command-signatures/json/bun.json @@ -551,7 +551,8 @@ "args": { "name": "package", "debounce": true, - "template": "filepaths" + "template": "filepaths", + "generatorName": "npms_search" } }, { diff --git a/command-signatures/json/cargo.json b/command-signatures/json/cargo.json index fa65cf17..a8646986 100644 --- a/command-signatures/json/cargo.json +++ b/command-signatures/json/cargo.json @@ -32,8 +32,8 @@ "isRepeatable": true, "args": { "name": "test", - "template": "filepaths", - "isVariadic": true + "isVariadic": true, + "generatorName": "test_targets" } }, { @@ -113,7 +113,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -321,8 +322,8 @@ "isRepeatable": true, "args": { "name": "test", - "template": "filepaths", - "isVariadic": true + "isVariadic": true, + "generatorName": "test_targets" } }, { @@ -379,7 +380,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -584,8 +586,8 @@ "isRepeatable": true, "args": { "name": "test", - "template": "filepaths", - "isVariadic": true + "isVariadic": true, + "generatorName": "test_targets" } }, { @@ -635,7 +637,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -795,7 +798,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -1212,7 +1216,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -1351,7 +1356,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -1486,8 +1492,8 @@ "isRepeatable": true, "args": { "name": "test", - "template": "filepaths", - "isVariadic": true + "isVariadic": true, + "generatorName": "test_targets" } }, { @@ -1537,7 +1543,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -1701,7 +1708,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -2236,7 +2244,8 @@ "name": "crate", "template": "filepaths", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "crates_io_search" } }, { @@ -2248,7 +2257,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -2506,7 +2516,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -2915,7 +2926,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -3043,7 +3055,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -3163,7 +3176,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -3287,7 +3301,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -3653,7 +3668,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -3810,8 +3826,8 @@ "isRepeatable": true, "args": { "name": "test", - "template": "filepaths", - "isVariadic": true + "isVariadic": true, + "generatorName": "test_targets" } }, { @@ -3876,7 +3892,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -4061,8 +4078,8 @@ "isRepeatable": true, "args": { "name": "test", - "template": "filepaths", - "isVariadic": true + "isVariadic": true, + "generatorName": "test_targets" } }, { @@ -4112,7 +4129,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -4335,7 +4353,8 @@ "template": "filepaths", "debounce": true, "isVariadic": true, - "suggestCurrentToken": true + "suggestCurrentToken": true, + "generatorName": "crates_io_search" } }, { @@ -4370,8 +4389,8 @@ "isRepeatable": true, "args": { "name": "test", - "template": "filepaths", - "isVariadic": true + "isVariadic": true, + "generatorName": "test_targets" } }, { @@ -4451,7 +4470,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -4603,7 +4623,8 @@ ], "args": [ { - "name": "TESTNAME" + "name": "TESTNAME", + "generatorName": "test_list" }, { "name": "args", @@ -4621,7 +4642,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -4984,7 +5006,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -5075,7 +5098,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -5191,7 +5215,8 @@ "description": "Path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -5602,7 +5627,8 @@ "description": "Path to the Cargo.toml file to use", "args": { "name": "PATH", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-rs" } }, { @@ -5724,7 +5750,8 @@ "name": "--", "description": "All other arguments are passed to rustfmt", "args": { - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-rs" }, "options": [ { @@ -5749,7 +5776,8 @@ "name": "--config-path", "description": "Path for the configuration file", "args": { - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-rustfmt-toml" } }, { @@ -5839,7 +5867,8 @@ "description": "Specify path to Cargo.toml", "args": { "name": "manifest-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-toml" } }, { @@ -5990,7 +6019,8 @@ "description": "Stdin" } ], - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-cargo-lock" } }, { @@ -6200,7 +6230,8 @@ "name": "DEP_ID", "template": "filepaths", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "crates_io_search" } } ], diff --git a/command-signatures/json/chown.json b/command-signatures/json/chown.json index a7af1c8d..c87460e3 100644 --- a/command-signatures/json/chown.json +++ b/command-signatures/json/chown.json @@ -4,7 +4,8 @@ "args": [ { "name": "owner[:group] or :group", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" }, { "name": "file/directory", diff --git a/command-signatures/json/cloudflared.json b/command-signatures/json/cloudflared.json index bd341fe0..98dce050 100644 --- a/command-signatures/json/cloudflared.json +++ b/command-signatures/json/cloudflared.json @@ -708,7 +708,8 @@ "args": { "name": "value", "description": "Config file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" }, "isRequired": true }, @@ -1239,7 +1240,8 @@ "args": { "name": "value", "description": "Config file in YAML", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { @@ -1554,7 +1556,8 @@ "args": { "name": "value", "description": "Config file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { @@ -1790,7 +1793,8 @@ "args": { "name": "value", "description": "Config file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { @@ -1964,7 +1968,8 @@ "args": { "name": "value", "description": "Config file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { @@ -2122,7 +2127,8 @@ "args": { "name": "value", "description": "Config file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { @@ -2280,7 +2286,8 @@ "args": { "name": "value", "description": "Config file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { @@ -2443,7 +2450,8 @@ "args": { "name": "value", "description": "Config file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { diff --git a/command-signatures/json/dd.json b/command-signatures/json/dd.json index 8abf23be..03e0996b 100644 --- a/command-signatures/json/dd.json +++ b/command-signatures/json/dd.json @@ -114,7 +114,7 @@ "requiresSeparator": true, "args": { "name": "value", - "template": "filepaths" + "generatorName": "conv_remaining" } } ] diff --git a/command-signatures/json/degit.json b/command-signatures/json/degit.json index 862d1da0..e332648f 100644 --- a/command-signatures/json/degit.json +++ b/command-signatures/json/degit.json @@ -4,7 +4,7 @@ "args": [ { "name": "user/repo", - "template": "filepaths" + "generatorName": "github_user_repos" }, { "name": "location", diff --git a/command-signatures/json/deno.json b/command-signatures/json/deno.json index 52a52738..e9758587 100644 --- a/command-signatures/json/deno.json +++ b/command-signatures/json/deno.json @@ -1280,7 +1280,7 @@ { "name": "filter", "isOptional": true, - "template": "filepaths" + "generatorName": "doc_json" } ] }, @@ -2150,7 +2150,7 @@ ], "args": { "name": "name", - "generatorName": "find_deno_bin_1_f" + "generatorName": "deno_binaries" } }, { @@ -3404,7 +3404,7 @@ "args": { "name": "version", "isOptional": true, - "generatorName": "curl_https_cdn_deno_land_deno_meta_versions_json" + "generatorName": "deno_versions" } }, { diff --git a/command-signatures/json/deployctl.json b/command-signatures/json/deployctl.json index d6c5ddb5..2f073e83 100644 --- a/command-signatures/json/deployctl.json +++ b/command-signatures/json/deployctl.json @@ -7,7 +7,8 @@ "description": "Deploy a script with static files to Deno Deploy", "args": { "name": "entrypoint", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-deployctl" }, "options": [ { @@ -59,7 +60,7 @@ "args": { "name": "version", "isOptional": true, - "generatorName": "curl_https_cdn_deno_land_deploy_meta_versions_json" + "generatorName": "deploy_versions" } } ], diff --git a/command-signatures/json/direnv.json b/command-signatures/json/direnv.json index 9ec35ecc..029d1c88 100644 --- a/command-signatures/json/direnv.json +++ b/command-signatures/json/direnv.json @@ -9,6 +9,7 @@ "args": { "name": "PATH_TO_RC", "template": "filepaths", + "filterTemplateName": "filter-envrc", "isOptional": true } }, @@ -19,6 +20,7 @@ "args": { "name": "PATH_TO_RC", "template": "filepaths", + "filterTemplateName": "filter-envrc", "isOptional": true } }, @@ -28,6 +30,7 @@ "args": { "name": "PATH_TO_RC", "template": "filepaths", + "filterTemplateName": "filter-envrc", "isOptional": true } }, @@ -166,7 +169,8 @@ }, { "name": "PATH_TO_DOTENV", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-envrc" } ] }, diff --git a/command-signatures/json/docker.json b/command-signatures/json/docker.json index ab4ca986..ad850ca8 100644 --- a/command-signatures/json/docker.json +++ b/command-signatures/json/docker.json @@ -177,7 +177,7 @@ "description": "Set the target build stage to build", "args": { "name": "target build stage", - "template": "filepaths" + "generatorName": "from_as" } } ] @@ -1495,7 +1495,8 @@ "args": { "name": "NAME[:TAG|@DIGEST]", "template": "filepaths", - "debounce": true + "debounce": true, + "generatorName": "search" }, "options": [ { @@ -2928,7 +2929,7 @@ "description": "Set the target build stage to build", "args": { "name": "target build stage", - "template": "filepaths" + "generatorName": "from_as" } } ] @@ -5639,7 +5640,7 @@ "description": "Set the target build stage to build", "args": { "name": "target build stage", - "template": "filepaths" + "generatorName": "from_as" } } ] @@ -5838,7 +5839,8 @@ "args": { "name": "NAME[:TAG|@DIGEST]", "template": "filepaths", - "debounce": true + "debounce": true, + "generatorName": "search" }, "options": [ { diff --git a/command-signatures/json/dtm.json b/command-signatures/json/dtm.json index 09baab82..9c0025d2 100644 --- a/command-signatures/json/dtm.json +++ b/command-signatures/json/dtm.json @@ -15,7 +15,8 @@ "args": { "name": "config-file", "default": "config.yaml", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { @@ -97,7 +98,8 @@ "args": { "name": "config-file", "default": "config.yaml", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { @@ -137,7 +139,8 @@ "args": { "name": "config-file", "default": "config.yaml", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { @@ -210,7 +213,8 @@ "args": { "name": "config-file", "default": "config.yaml", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { @@ -340,7 +344,8 @@ "args": { "name": "config-file", "default": "config.yaml", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" } }, { diff --git a/command-signatures/json/elixir.json b/command-signatures/json/elixir.json index 2b92d776..5d2d5e3c 100644 --- a/command-signatures/json/elixir.json +++ b/command-signatures/json/elixir.json @@ -5,7 +5,8 @@ { "name": "file", "description": ".exs file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-exs" }, { "name": "data", diff --git a/command-signatures/json/elm.json b/command-signatures/json/elm.json index 6cf5c408..893465d3 100644 --- a/command-signatures/json/elm.json +++ b/command-signatures/json/elm.json @@ -58,7 +58,7 @@ "name": "package", "description": "The name of the package to install", "debounce": true, - "generatorName": "curl_accept_encoding_gzip_https_package_elm_lang_org_search_json" + "generatorName": "elm_packages" }, "options": [ { diff --git a/command-signatures/json/esbuild.json b/command-signatures/json/esbuild.json index 0be3a385..d0c36f23 100644 --- a/command-signatures/json/esbuild.json +++ b/command-signatures/json/esbuild.json @@ -56,7 +56,7 @@ "requiresSeparator": ":", "args": { "name": "loaders", - "template": "filepaths" + "generatorName": "loader" }, "priority": 51 }, @@ -160,7 +160,7 @@ "requiresSeparator": ":", "args": { "name": "ext=text[,ext=text...]", - "template": "filepaths" + "generatorName": "loader" } }, { @@ -218,7 +218,7 @@ "requiresSeparator": ":", "args": { "name": "ext=text", - "template": "filepaths" + "generatorName": "loader" } }, { @@ -239,7 +239,7 @@ "requiresSeparator": ":", "args": { "name": "import", - "template": "filepaths" + "generatorName": "loader" } }, { @@ -333,7 +333,7 @@ "requiresSeparator": ":", "args": { "name": "identifier:level", - "template": "filepaths" + "generatorName": "loader" } }, { @@ -403,7 +403,7 @@ "requiresSeparator": ":", "args": { "name": "ext=new", - "template": "filepaths" + "generatorName": "loader" } }, { @@ -433,7 +433,8 @@ "description": "Mark the name as a pure function for tree shaking", "requiresSeparator": ":", "args": { - "name": "name" + "name": "name", + "generatorName": "loader" } }, { @@ -516,7 +517,7 @@ "requiresSeparator": ":", "args": { "name": "syntax=status", - "template": "filepaths" + "generatorName": "loader" } }, { diff --git a/command-signatures/json/eslint.json b/command-signatures/json/eslint.json index 57af6dac..a21b8df2 100644 --- a/command-signatures/json/eslint.json +++ b/command-signatures/json/eslint.json @@ -22,7 +22,8 @@ "name": "--env", "description": "Specify environments", "args": { - "template": "filepaths" + "template": "filepaths", + "generatorName": "env_remaining" } }, { diff --git a/command-signatures/json/expo-cli.json b/command-signatures/json/expo-cli.json index a1995113..48b73299 100644 --- a/command-signatures/json/expo-cli.json +++ b/command-signatures/json/expo-cli.json @@ -1852,7 +1852,8 @@ "isOptional": true, "isVariadic": true, "name": "packages", - "debounce": true + "debounce": true, + "generatorName": "npms_search" }, "options": [ { diff --git a/command-signatures/json/expo.json b/command-signatures/json/expo.json index 5b488fde..f31156ab 100644 --- a/command-signatures/json/expo.json +++ b/command-signatures/json/expo.json @@ -1852,7 +1852,8 @@ "isOptional": true, "isVariadic": true, "name": "packages", - "debounce": true + "debounce": true, + "generatorName": "npms_search" }, "options": [ { diff --git a/command-signatures/json/fig-teams.json b/command-signatures/json/fig-teams@latest.json similarity index 91% rename from command-signatures/json/fig-teams.json rename to command-signatures/json/fig-teams@latest.json index 2ccecfce..5ed4fa55 100644 --- a/command-signatures/json/fig-teams.json +++ b/command-signatures/json/fig-teams@latest.json @@ -34,7 +34,7 @@ "description": "Team to use", "args": { "name": "teamname", - "generatorName": "npx_fig_teams_latest_teams" + "generatorName": "teams_list" } }, { @@ -55,13 +55,13 @@ "description": "Team to use", "args": { "name": "teamname", - "generatorName": "npx_fig_teams_latest_teams" + "generatorName": "teams_list" } } ], "args": { "name": "email", - "template": "filepaths" + "generatorName": "users_for_selected_team" } }, { @@ -76,13 +76,13 @@ "description": "Team to use", "args": { "name": "teamname", - "generatorName": "npx_fig_teams_latest_teams" + "generatorName": "teams_list" } } ], "args": { "name": "email", - "template": "filepaths" + "generatorName": "users_for_selected_team" } } ] diff --git a/command-signatures/json/file.json b/command-signatures/json/file.json index b92358ee..702449fc 100644 --- a/command-signatures/json/file.json +++ b/command-signatures/json/file.json @@ -189,7 +189,7 @@ "isRepeatable": true, "args": { "name": "name=value", - "template": "filepaths" + "generatorName": "param_keys" } }, { diff --git a/command-signatures/json/gh.json b/command-signatures/json/gh.json index 6d69e7f4..7c050a70 100644 --- a/command-signatures/json/gh.json +++ b/command-signatures/json/gh.json @@ -2044,7 +2044,10 @@ { "name": "repository", "template": "filepaths", - "generatorName": "api_graphql_string_viewer" + "generatorName": [ + "api_graphql_string_viewer", + "repo_list_owner" + ] }, { "name": "directory", @@ -2251,7 +2254,10 @@ "args": { "name": "repository", "template": "filepaths", - "generatorName": "api_graphql_string_viewer" + "generatorName": [ + "api_graphql_string_viewer", + "repo_list_owner" + ] }, "options": [ { @@ -2425,7 +2431,10 @@ "name": "repository", "isOptional": true, "template": "filepaths", - "generatorName": "api_graphql_string_viewer" + "generatorName": [ + "api_graphql_string_viewer", + "repo_list_owner" + ] }, "options": [ { diff --git a/command-signatures/json/git-flow.json b/command-signatures/json/git-flow.json index 1ebdf26e..4aafcbf4 100644 --- a/command-signatures/json/git-flow.json +++ b/command-signatures/json/git-flow.json @@ -34,7 +34,7 @@ "args": { "name": "name", "description": "The name of the feature branch to finish", - "template": "filepaths" + "generatorName": "type_branches" } }, { @@ -79,7 +79,7 @@ "args": { "name": "name", "description": "The name of the release branch to finish", - "template": "filepaths" + "generatorName": "type_branches" } } ] @@ -102,7 +102,7 @@ "args": { "name": "name", "description": "The name of the hotfix branch to finish", - "template": "filepaths" + "generatorName": "type_branches" } } ] diff --git a/command-signatures/json/hub.json b/command-signatures/json/hub.json index 181f5de5..a0bd131d 100644 --- a/command-signatures/json/hub.json +++ b/command-signatures/json/hub.json @@ -1,8 +1,7 @@ { - "name": "git", + "name": "hub", "description": "The stupid content tracker", "generateSpec": "_NuFrRa_(o,t)=>p(void 0,null,function*(){let r=(yield t(\"compgen -c | grep git- | cut -c5- | sort -u\")).trim();return r===\"\"?{name:\"git\"}:{name:\"git\",subcommands:r.split(`\n`).map(a=>{var s;return f({name:a},(s=q[a])!=null?s:{description:`Run git-${a}`})})}})", - "args": { "name": "alias", "description": "Custom user defined git alias", @@ -4069,7 +4068,10 @@ } ], "template": "filepaths", - "generatorName": "log" + "generatorName": [ + "log", + "status_staged_or_unstaged" + ] } }, { diff --git a/command-signatures/json/iex.json b/command-signatures/json/iex.json index 3e97be67..d6364841 100644 --- a/command-signatures/json/iex.json +++ b/command-signatures/json/iex.json @@ -5,7 +5,8 @@ { "name": "file", "description": ".exs file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-exs" }, { "name": "data", diff --git a/command-signatures/json/j.json b/command-signatures/json/j.json index 6c6b1dbb..9fe48d24 100644 --- a/command-signatures/json/j.json +++ b/command-signatures/json/j.json @@ -1,5 +1,5 @@ { - "name": "autojump", + "name": "j", "description": "A faster way to navigate your filesystem", "options": [ { diff --git a/command-signatures/json/java.json b/command-signatures/json/java.json index 5026a5e8..1f0fd245 100644 --- a/command-signatures/json/java.json +++ b/command-signatures/json/java.json @@ -7,7 +7,8 @@ "args": { "name": "mainclass", "description": "To launch a class file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-java-class" }, "options": [ { @@ -16,7 +17,8 @@ "description": "To launch the main class in a JAR file", "args": { "name": "JAR file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-jar" } }, { diff --git a/command-signatures/json/julia.json b/command-signatures/json/julia.json index 26edad8f..c4a97a88 100644 --- a/command-signatures/json/julia.json +++ b/command-signatures/json/julia.json @@ -45,7 +45,8 @@ "description": "Start up with the given system image file", "args": { "name": "system image", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-dylib-so-dll" } }, { @@ -144,7 +145,8 @@ "description": "Load given file immediately on all processors", "args": { "name": "julia script", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-jl" } }, { @@ -510,6 +512,7 @@ "name": "julia script", "isScript": true, "isOptional": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-jl" } } diff --git a/command-signatures/json/limactl.json b/command-signatures/json/limactl.json index 7c6adc92..f5cb47c6 100644 --- a/command-signatures/json/limactl.json +++ b/command-signatures/json/limactl.json @@ -337,6 +337,7 @@ "args": { "name": "NAME|FILE.yaml|URL", "template": "filepaths", + "filterTemplateName": "filter-yml-yaml", "generatorName": "list" }, "options": [ @@ -419,7 +420,8 @@ "args": { "name": "FILE.yaml", "isVariadic": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yml-yaml" }, "options": [ { diff --git a/command-signatures/json/man.json b/command-signatures/json/man.json index 7a6c9809..c5149e1b 100644 --- a/command-signatures/json/man.json +++ b/command-signatures/json/man.json @@ -104,7 +104,7 @@ "description": "Specify a colon-separated list of manual sections to search", "args": { "name": "sections", - "template": "filepaths" + "generatorName": "sections_remaining" } }, { diff --git a/command-signatures/json/meteor.json b/command-signatures/json/meteor.json index 92047358..a365abfd 100644 --- a/command-signatures/json/meteor.json +++ b/command-signatures/json/meteor.json @@ -103,7 +103,8 @@ "description": "Set optional data for Meteor.settings on the server", "args": { "name": "JSON File", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-json" } }, { @@ -464,7 +465,8 @@ "description": "Set optional data for Meteor.settings", "args": { "name": "JSON File", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-json" } }, { @@ -633,7 +635,8 @@ "description": "Set optional data for Meteor.settings on the server", "args": { "name": "JSON File", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-json" } }, { @@ -753,7 +756,8 @@ "description": "Set optional data for Meteor.settings on the server", "args": { "name": "JSON File", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-json" } }, { @@ -905,7 +909,8 @@ "description": "Publishes a new release to the package server, as determined by a JSON configuration file", "args": { "name": "JSON File", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-json" }, "options": [ { diff --git a/command-signatures/json/mix.json b/command-signatures/json/mix.json index 0e07cbf7..fbd6b5fc 100644 --- a/command-signatures/json/mix.json +++ b/command-signatures/json/mix.json @@ -46,7 +46,8 @@ "args": { "name": "file", "template": "filepaths", - "isOptional": true + "isOptional": true, + "filterTemplateName": "filter-exs" }, "options": [ { @@ -78,7 +79,8 @@ "args": { "name": "file|pattern", "description": "The file|pattern to execute", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-exs" } }, { @@ -89,7 +91,8 @@ "description": "Executes the given pattern/file", "args": { "name": "file|pattern", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-exs" } }, { diff --git a/command-signatures/json/n.json b/command-signatures/json/n.json index 128de5d6..06cd8c1b 100644 --- a/command-signatures/json/n.json +++ b/command-signatures/json/n.json @@ -198,7 +198,8 @@ { "name": "node script", "isScript": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-js-ts-family" } ], "options": [ diff --git a/command-signatures/json/nativescript.json b/command-signatures/json/nativescript.json index dc169d36..2b3e20a8 100644 --- a/command-signatures/json/nativescript.json +++ b/command-signatures/json/nativescript.json @@ -1,5 +1,5 @@ { - "name": "ns", + "name": "nativescript", "description": "The NativeScript CLI lets you create, build, and deploy NativeScript based apps on iOS and Android devices", "subcommands": [ { @@ -237,7 +237,7 @@ "description": "Create a project using a predefined template", "args": { "name": "template", - "generatorName": "curl_https_api_github_com_repos_nativescript_nativescript_app_templates_contents_packages" + "generatorName": "nativescript_templates" } }, { diff --git a/command-signatures/json/ni.json b/command-signatures/json/ni.json index ce537e2b..2f5df192 100644 --- a/command-signatures/json/ni.json +++ b/command-signatures/json/ni.json @@ -43,6 +43,7 @@ "name": "package", "template": "filepaths", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "npms_search" } } diff --git a/command-signatures/json/npm.json b/command-signatures/json/npm.json index ea812537..8a6f265c 100644 --- a/command-signatures/json/npm.json +++ b/command-signatures/json/npm.json @@ -374,7 +374,8 @@ "isOptional": true, "template": "filepaths", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "npms_search" }, "options": [ { @@ -599,7 +600,8 @@ "isOptional": true, "template": "filepaths", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "npms_search" }, "options": [ { @@ -1639,7 +1641,8 @@ "isOptional": true, "template": "filepaths", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "npms_search" }, "options": [ { diff --git a/command-signatures/json/ns.json b/command-signatures/json/ns.json index dc169d36..7de73f1c 100644 --- a/command-signatures/json/ns.json +++ b/command-signatures/json/ns.json @@ -237,7 +237,7 @@ "description": "Create a project using a predefined template", "args": { "name": "template", - "generatorName": "curl_https_api_github_com_repos_nativescript_nativescript_app_templates_contents_packages" + "generatorName": "nativescript_templates" } }, { diff --git a/command-signatures/json/nx.json b/command-signatures/json/nx.json index a39e449a..30cdf352 100644 --- a/command-signatures/json/nx.json +++ b/command-signatures/json/nx.json @@ -228,7 +228,8 @@ "description": "Run a generator", "args": { "template": "filepaths", - "name": "collection:generator" + "name": "collection:generator", + "generatorName": "plugin_list" }, "options": [ { diff --git a/command-signatures/json/osascript.json b/command-signatures/json/osascript.json index 3b535533..771fe85d 100644 --- a/command-signatures/json/osascript.json +++ b/command-signatures/json/osascript.json @@ -51,6 +51,7 @@ "name": "script", "isScript": true, "isOptional": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-scpt" } } diff --git a/command-signatures/json/pandoc.json b/command-signatures/json/pandoc.json index def83fe7..742548e1 100644 --- a/command-signatures/json/pandoc.json +++ b/command-signatures/json/pandoc.json @@ -55,7 +55,8 @@ "description": "Specify a set of default option settings", "args": { "name": "file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yaml" } }, { @@ -184,7 +185,8 @@ "description": "Read metadata from the supplied YAML (or JSON) file", "args": { "name": "file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-yaml-json" } }, { diff --git a/command-signatures/json/pdfunite.json b/command-signatures/json/pdfunite.json index 545e8037..beb2d99c 100644 --- a/command-signatures/json/pdfunite.json +++ b/command-signatures/json/pdfunite.json @@ -17,6 +17,7 @@ ], "args": { "template": "filepaths", - "isVariadic": true + "isVariadic": true, + "filterTemplateName": "filter-pdf" } } diff --git a/command-signatures/json/pm2.json b/command-signatures/json/pm2.json index 77e9c720..ae688f7c 100644 --- a/command-signatures/json/pm2.json +++ b/command-signatures/json/pm2.json @@ -426,7 +426,8 @@ "description": "Start or restart JSON file", "args": { "name": "json", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-json" } }, { @@ -434,7 +435,8 @@ "description": "Start or gracefully reload JSON file", "args": { "name": "json", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-json" } }, { @@ -450,7 +452,8 @@ "description": "Start or gracefully reolad JSON file", "args": { "name": "json", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-json" } }, { diff --git a/command-signatures/json/pnpm.json b/command-signatures/json/pnpm.json index ddefc84f..8450e97b 100644 --- a/command-signatures/json/pnpm.json +++ b/command-signatures/json/pnpm.json @@ -28,7 +28,8 @@ "args": { "name": "package", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "npms_search" }, "options": [ { @@ -131,7 +132,6 @@ ], "description": "Pnpm install is used to install all dependencies for a project.\nIn a CI environment, installation fails if a lockfile is present but needs an update.\nInside a workspace, pnpm install installs all dependencies in all the projects.\nIf you want to disable this behavior, set the recursive-install setting to false", "generateSpec": "_NuFrRa_generateSpec(e){return h(this,null,function*(){let n=e.filter(t=>t.trim()!==\"\"&&!t.startsWith(\"-\")).length>2;return{name:\"install\",options:[...F,...n?G:M]}})}", - "args": { "name": "package", "isOptional": true, @@ -916,7 +916,8 @@ "name": "package", "template": "filepaths", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "npms_search" }, "options": [ { @@ -1019,13 +1020,13 @@ ], "description": "Pnpm install is used to install all dependencies for a project.\nIn a CI environment, installation fails if a lockfile is present but needs an update.\nInside a workspace, pnpm install installs all dependencies in all the projects.\nIf you want to disable this behavior, set the recursive-install setting to false", "generateSpec": "_NuFrRa_generateSpec(e){return h(this,null,function*(){let n=e.filter(t=>t.trim()!==\"\"&&!t.startsWith(\"-\")).length>2;return{name:\"install\",options:[...F,...n?G:M]}})}", - "args": { "name": "package", "isOptional": true, "template": "filepaths", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "npms_search" } }, { diff --git a/command-signatures/json/pod.json b/command-signatures/json/pod.json index 599850d2..e87f7130 100644 --- a/command-signatures/json/pod.json +++ b/command-signatures/json/pod.json @@ -308,7 +308,8 @@ "args": { "name": "NAME.podspec|DIRECTORY|http://PATH/NAME.podspec", "isOptional": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-podspec" } } ] @@ -682,7 +683,8 @@ "description": "Additional ancillary podspecs which are used for linting via :path", "args": { "name": "podspec", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-podspec" } }, { @@ -690,7 +692,8 @@ "description": "Additional ancillary podspecs which are used for linting via :podspec. If there are --include-podspecs, then these are removed from them", "args": { "name": "podspec", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-podspec" } }, { @@ -727,7 +730,8 @@ "args": { "name": "PODSPEC_PATHS", "isOptional": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-podspec" } } ] @@ -869,7 +873,8 @@ { "name": "NAME.podspec", "isOptional": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-podspec" } ] }, diff --git a/command-signatures/json/python.json b/command-signatures/json/python.json index 0b4c1c40..6daba112 100644 --- a/command-signatures/json/python.json +++ b/command-signatures/json/python.json @@ -7,6 +7,7 @@ "name": "python script", "isScript": true, "template": "filepaths", + "filterTemplateName": "filter-py", "skipGeneratorValidation": false }, "options": [ diff --git a/command-signatures/json/python3.json b/command-signatures/json/python3.json index a5da1b6a..990c9625 100644 --- a/command-signatures/json/python3.json +++ b/command-signatures/json/python3.json @@ -7,6 +7,7 @@ "name": "python script", "isScript": true, "template": "filepaths", + "filterTemplateName": "filter-py", "skipGeneratorValidation": false }, "options": [ diff --git a/command-signatures/json/r.json b/command-signatures/json/r.json index c3e89819..595ef6b0 100644 --- a/command-signatures/json/r.json +++ b/command-signatures/json/r.json @@ -41,7 +41,8 @@ { "name": "infile", "description": "A file with R code to be executed", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-r-src" }, { "name": "outfile", @@ -72,7 +73,8 @@ "name": "files", "description": "Source files to be compiled", "isVariadic": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-r-archive" } }, { @@ -149,7 +151,8 @@ "name": "files", "description": "The object files to be included in the shared object/DLL", "isVariadic": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-r-archive" } }, { @@ -789,7 +792,8 @@ "name": "packages", "description": "Packages to check", "isVariadic": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-r-archive" } }, { @@ -989,7 +993,8 @@ "args": { "name": "file", "description": "R doc file to convert", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-rd" } }, { @@ -1225,7 +1230,8 @@ "args": { "name": "file", "description": "R doc file to convert", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-r" } }, { @@ -1849,7 +1855,8 @@ "args": { "name": "file", "description": "File to run", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-r" } }, { diff --git a/command-signatures/json/rancher.json b/command-signatures/json/rancher.json index 8649cb63..3973799f 100644 --- a/command-signatures/json/rancher.json +++ b/command-signatures/json/rancher.json @@ -43,7 +43,8 @@ "description": "Path to an answers file, the format of the file is a map with key:value. This supports JSON and YAML", "args": { "name": "answers-file-path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-json-yaml" } }, { diff --git a/command-signatures/json/robot.json b/command-signatures/json/robot.json index 3a1e9dfb..ade0b083 100644 --- a/command-signatures/json/robot.json +++ b/command-signatures/json/robot.json @@ -5,7 +5,8 @@ "name": "robot script", "isScript": true, "isVariadic": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-robot" }, "options": [ { @@ -82,7 +83,7 @@ "description": "Select tests by name or by long name containing also parent suite name like `Parent.Test`", "args": { "name": "name", - "generatorName": "for_i_in_robot" + "generatorName": "test_cases" } }, { @@ -90,7 +91,7 @@ "description": "Alias to --test. Especially applicable with --rpa", "args": { "name": "name", - "generatorName": "for_i_in_robot" + "generatorName": "test_cases" } }, { @@ -133,7 +134,8 @@ "description": "Select failed tests from an earlier output file to be re-executed", "args": { "name": "output file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-xml" } }, { @@ -144,7 +146,8 @@ "description": "Select failed suites from an earlier output file to be re-executed", "args": { "name": "output file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-xml" } }, { @@ -175,7 +178,7 @@ "description": "Set variables in the test data", "args": { "name": "variable", - "template": "filepaths" + "generatorName": "variables" } }, { @@ -186,7 +189,8 @@ "description": "Python or YAML file file to read variables from", "args": { "name": "file", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-py-yaml" } }, { @@ -386,7 +390,7 @@ "description": "Include only matching tags in `Statistics by Tag` in log and report", "args": { "name": "tag", - "generatorName": "for_i_in_robot" + "generatorName": "test_cases" } }, { @@ -394,7 +398,7 @@ "description": "Exclude matching tags from `Statistics by Tag`", "args": { "name": "tag", - "generatorName": "for_i_in_robot" + "generatorName": "test_cases" } }, { @@ -402,7 +406,7 @@ "description": "Create combined statistics based on tags. These statistics are added into `Statistics by Tag`", "args": { "name": "tags:name", - "generatorName": "for_i_in_robot" + "generatorName": "test_cases" } }, { @@ -410,7 +414,7 @@ "description": "Add documentation to tags matching the given pattern", "args": { "name": "pattern:doc", - "generatorName": "for_i_in_robot" + "generatorName": "test_cases" } }, { @@ -418,7 +422,7 @@ "description": "Add external links into `Statistics by Tag`. Pattern can use `*`, `?` and `[]` as wildcards", "args": { "name": "pattern:link:title", - "generatorName": "for_i_in_robot" + "generatorName": "test_cases" } }, { @@ -718,7 +722,8 @@ "description": "Additional locations (directories, ZIPs) where to search libraries and other extensions when they are imported", "args": { "name": "path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-zip" } }, { diff --git a/command-signatures/json/rollup.json b/command-signatures/json/rollup.json index 95949235..2cc8c5ff 100644 --- a/command-signatures/json/rollup.json +++ b/command-signatures/json/rollup.json @@ -10,7 +10,8 @@ "description": "Use this config file (if argument is used but value is unspecified, defaults to rollup.config.js)", "args": { "name": "filename", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-config-js" } }, { diff --git a/command-signatures/json/rscript.json b/command-signatures/json/rscript.json index 6c447880..855729cc 100644 --- a/command-signatures/json/rscript.json +++ b/command-signatures/json/rscript.json @@ -70,7 +70,8 @@ "name": "file", "description": "R script to run", "isScript": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-r" }, { "name": "args", diff --git a/command-signatures/json/rush.json b/command-signatures/json/rush.json index 1eba6449..0c34597f 100644 --- a/command-signatures/json/rush.json +++ b/command-signatures/json/rush.json @@ -17,7 +17,8 @@ "args": { "name": "PACKAGE", "template": "filepaths", - "debounce": true + "debounce": true, + "generatorName": "npms_search" } }, { diff --git a/command-signatures/json/rustup.json b/command-signatures/json/rustup.json index c5fdc1e3..3a89c756 100644 --- a/command-signatures/json/rustup.json +++ b/command-signatures/json/rustup.json @@ -676,7 +676,7 @@ "args": { "name": "", "description": "Topic such as 'core', 'fn', 'usize', 'eprintln!', 'core::arch', 'alloc::format!', 'std::fs', 'std::fs::read_dir', 'std::io::Bytes', 'std::iter::Sum', 'std::io::error::Result' etc", - "generatorName": "find_docs_s_index_html" + "generatorName": "rustup_docs" } }, { diff --git a/command-signatures/json/scc.json b/command-signatures/json/scc.json index 3e239779..094c1ab1 100644 --- a/command-signatures/json/scc.json +++ b/command-signatures/json/scc.json @@ -109,7 +109,8 @@ { "name": "sql-insert" } - ] + ], + "generatorName": "format_multi" } }, { diff --git a/command-signatures/json/shortcuts.json b/command-signatures/json/shortcuts.json index 87bac52f..c3e18c91 100644 --- a/command-signatures/json/shortcuts.json +++ b/command-signatures/json/shortcuts.json @@ -110,7 +110,8 @@ "description": "The shortcut file to sign", "args": { "name": "input", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-shortcut" } }, { diff --git a/command-signatures/json/sqlite3.json b/command-signatures/json/sqlite3.json index f19bbd7d..61916890 100644 --- a/command-signatures/json/sqlite3.json +++ b/command-signatures/json/sqlite3.json @@ -6,7 +6,8 @@ }, "args": { "name": "FILENAME", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-sqlite" }, "options": [ { @@ -49,7 +50,8 @@ "description": "Read/process named file", "args": { "name": "FILENAME", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-sqlite" } }, { diff --git a/command-signatures/json/st2.json b/command-signatures/json/st2.json index 54b7acd5..262bff0e 100644 --- a/command-signatures/json/st2.json +++ b/command-signatures/json/st2.json @@ -126,7 +126,8 @@ "description": "User under which to run the action (admins only)", "args": { "name": "USER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" } } ], @@ -662,7 +663,8 @@ "description": "User under which to run the action (admins only)", "args": { "name": "USER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" } } ], @@ -1104,7 +1106,8 @@ "description": "User under which to run the action (admins only)", "args": { "name": "USER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" } } ], @@ -1340,7 +1343,8 @@ "description": "User under which to run the action (admins only)", "args": { "name": "USER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" } }, { @@ -1468,7 +1472,8 @@ "description": "User under which to run the action (admins only)", "args": { "name": "USER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" } }, { @@ -1861,7 +1866,8 @@ "description": "User under which to run the action (admins only)", "args": { "name": "USER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" } }, { @@ -2705,7 +2711,8 @@ "description": "User under which to run the action (admins only)", "args": { "name": "USER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" } }, { @@ -2860,7 +2867,8 @@ "description": "User under which to run the action (admins only)", "args": { "name": "USER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" } } ], @@ -2950,7 +2958,8 @@ "description": "User under which to run the action (admins only)", "args": { "name": "USER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" } } ], @@ -6923,7 +6932,8 @@ "description": "User under which to run the action (admins only)", "args": { "name": "USER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "users_or_groups" } }, { diff --git a/command-signatures/json/stepzen.json b/command-signatures/json/stepzen.json index 77e1d83e..3bf5700f 100644 --- a/command-signatures/json/stepzen.json +++ b/command-signatures/json/stepzen.json @@ -59,7 +59,7 @@ "args": { "name": "name", "description": "The name of the generator to import", - "generatorName": "curl_https_api_github_com_repos_steprz_stepzen_schemas_contents" + "generatorName": "github_schemas" }, "options": [ { diff --git a/command-signatures/json/subl.json b/command-signatures/json/subl.json index 2299a4a6..bd0f79e3 100644 --- a/command-signatures/json/subl.json +++ b/command-signatures/json/subl.json @@ -16,7 +16,8 @@ "description": "Load the given project", "args": { "name": "project", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-sublime" } }, { diff --git a/command-signatures/json/tailscale.json b/command-signatures/json/tailscale.json index 1a77f17f..97cfddfb 100644 --- a/command-signatures/json/tailscale.json +++ b/command-signatures/json/tailscale.json @@ -343,7 +343,7 @@ "name": "file or host", "isVariadic": true, "template": "filepaths", - "generatorName": "status" + "generatorName": "peers_colon" } ] }, diff --git a/command-signatures/json/tns.json b/command-signatures/json/tns.json index dc169d36..0da63a03 100644 --- a/command-signatures/json/tns.json +++ b/command-signatures/json/tns.json @@ -1,5 +1,5 @@ { - "name": "ns", + "name": "tns", "description": "The NativeScript CLI lets you create, build, and deploy NativeScript based apps on iOS and Android devices", "subcommands": [ { @@ -237,7 +237,7 @@ "description": "Create a project using a predefined template", "args": { "name": "template", - "generatorName": "curl_https_api_github_com_repos_nativescript_nativescript_app_templates_contents_packages" + "generatorName": "nativescript_templates" } }, { diff --git a/command-signatures/json/trivy.json b/command-signatures/json/trivy.json index 0a011238..cae12c45 100644 --- a/command-signatures/json/trivy.json +++ b/command-signatures/json/trivy.json @@ -44,8 +44,8 @@ "description": "Severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]", "args": { "name": "severity", - "template": "filepaths", - "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL" + "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL", + "generatorName": "severity_remaining" } }, { @@ -79,8 +79,8 @@ "description": "Comma-separated list of vulnerability types (os,library) (default: \"os,library\") [$TRIVY_VULN_TYPE]", "args": { "name": "vulnType", - "template": "filepaths", - "default": "os,library" + "default": "os,library", + "generatorName": "pkg_types_remaining" } }, { @@ -88,8 +88,8 @@ "description": "Comma-separated list of what security issues to detect (vuln,config) (default: \"vuln\") [$TRIVY_SECURITY_CHECKS]", "args": { "name": "securityChecks", - "template": "filepaths", - "default": "vuln" + "default": "vuln", + "generatorName": "scanners_remaining" } }, { @@ -243,8 +243,8 @@ "description": "Severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]", "args": { "name": "severity", - "template": "filepaths", - "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL" + "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL", + "generatorName": "severity_remaining" } }, { @@ -278,8 +278,8 @@ "description": "Comma-separated list of vulnerability types (os,library) (default: \"os,library\") [$TRIVY_VULN_TYPE]", "args": { "name": "vulnType", - "template": "filepaths", - "default": "os,library" + "default": "os,library", + "generatorName": "pkg_types_remaining" } }, { @@ -287,8 +287,8 @@ "description": "Comma-separated list of what security issues to detect (vuln,config) (default: \"vuln\") [$TRIVY_SECURITY_CHECKS]", "args": { "name": "securityChecks", - "template": "filepaths", - "default": "vuln" + "default": "vuln", + "generatorName": "scanners_remaining" } }, { @@ -468,8 +468,8 @@ "description": "Severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]", "args": { "name": "severity", - "template": "filepaths", - "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL" + "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL", + "generatorName": "severity_remaining" } }, { @@ -503,8 +503,8 @@ "description": "Comma-separated list of vulnerability types (os,library) (default: \"os,library\") [$TRIVY_VULN_TYPE]", "args": { "name": "vulnType", - "template": "filepaths", - "default": "os,library" + "default": "os,library", + "generatorName": "pkg_types_remaining" } }, { @@ -512,8 +512,8 @@ "description": "Comma-separated list of what security issues to detect (vuln,config) (default: \"vuln\") [$TRIVY_SECURITY_CHECKS]", "args": { "name": "securityChecks", - "template": "filepaths", - "default": "vuln" + "default": "vuln", + "generatorName": "scanners_remaining" } }, { @@ -668,8 +668,8 @@ "description": "Severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]", "args": { "name": "severity", - "template": "filepaths", - "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL" + "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL", + "generatorName": "severity_remaining" } }, { @@ -767,8 +767,8 @@ "description": "Severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]", "args": { "name": "severity", - "template": "filepaths", - "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL" + "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL", + "generatorName": "severity_remaining" } }, { @@ -802,8 +802,8 @@ "description": "Comma-separated list of vulnerability types (os,library) (default: \"os,library\") [$TRIVY_VULN_TYPE]", "args": { "name": "vulnType", - "template": "filepaths", - "default": "os,library" + "default": "os,library", + "generatorName": "pkg_types_remaining" } }, { @@ -811,8 +811,8 @@ "description": "Comma-separated list of what security issues to detect (vuln,config) (default: \"vuln\") [$TRIVY_SECURITY_CHECKS]", "args": { "name": "securityChecks", - "template": "filepaths", - "default": "vuln" + "default": "vuln", + "generatorName": "scanners_remaining" } }, { @@ -961,8 +961,8 @@ "description": "Severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]", "args": { "name": "severity", - "template": "filepaths", - "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL" + "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL", + "generatorName": "severity_remaining" } }, { @@ -996,8 +996,8 @@ "description": "Comma-separated list of vulnerability types (os,library) (default: \"os,library\") [$TRIVY_VULN_TYPE]", "args": { "name": "vulnType", - "template": "filepaths", - "default": "os,library" + "default": "os,library", + "generatorName": "pkg_types_remaining" } }, { @@ -1005,8 +1005,8 @@ "description": "Comma-separated list of what security issues to detect (vuln,config) (default: \"vuln\") [$TRIVY_SECURITY_CHECKS]", "args": { "name": "securityChecks", - "template": "filepaths", - "default": "vuln" + "default": "vuln", + "generatorName": "scanners_remaining" } }, { @@ -1078,8 +1078,8 @@ "description": "Severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]", "args": { "name": "severity", - "template": "filepaths", - "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL" + "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL", + "generatorName": "severity_remaining" } }, { @@ -1268,8 +1268,8 @@ "description": "Severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]", "args": { "name": "severity", - "template": "filepaths", - "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL" + "default": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL", + "generatorName": "severity_remaining" } }, { diff --git a/command-signatures/json/ts-node.json b/command-signatures/json/ts-node.json index 4082dc41..2b5354fa 100644 --- a/command-signatures/json/ts-node.json +++ b/command-signatures/json/ts-node.json @@ -93,7 +93,8 @@ "description": "Specify TypeScript project location", "args": { "name": "project", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-tsconfig" } }, { @@ -186,6 +187,7 @@ "args": { "name": "script", "isScript": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-ts-tsx" } } diff --git a/command-signatures/json/tsc.json b/command-signatures/json/tsc.json index 2fa53cec..3a433ec1 100644 --- a/command-signatures/json/tsc.json +++ b/command-signatures/json/tsc.json @@ -659,6 +659,7 @@ "args": { "name": "tsc script", "isScript": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-ts" } } diff --git a/command-signatures/json/vsce.json b/command-signatures/json/vsce.json index 2a1c68fb..b8db4dbd 100644 --- a/command-signatures/json/vsce.json +++ b/command-signatures/json/vsce.json @@ -49,7 +49,8 @@ "description": "Output .vsix extension file to location (defaults to -.vsix)", "args": { "name": "path", - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-vsix" } }, { @@ -225,7 +226,8 @@ "args": { "name": "paths", "isVariadic": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-vsix" } }, { diff --git a/command-signatures/json/wasm-bindgen.json b/command-signatures/json/wasm-bindgen.json index f0fdd0de..7b1bceb5 100644 --- a/command-signatures/json/wasm-bindgen.json +++ b/command-signatures/json/wasm-bindgen.json @@ -169,6 +169,7 @@ "name": "input", "description": "File name to output the compiled binary bindings", "isScript": true, - "template": "filepaths" + "template": "filepaths", + "filterTemplateName": "filter-wasm" } } diff --git a/command-signatures/json/xcodeproj.json b/command-signatures/json/xcodeproj.json index 71fd4b7f..c02d5acd 100644 --- a/command-signatures/json/xcodeproj.json +++ b/command-signatures/json/xcodeproj.json @@ -9,7 +9,8 @@ { "name": "PROJECT", "isOptional": true, - "template": "folders" + "template": "folders", + "filterTemplateName": "filter-xcodeproj" }, { "name": "OUTPUT", @@ -35,11 +36,13 @@ "args": [ { "name": "PROJECT1", - "template": "folders" + "template": "folders", + "filterTemplateName": "filter-xcodeproj" }, { "name": "PROJECT2", - "template": "folders" + "template": "folders", + "filterTemplateName": "filter-xcodeproj" } ] }, @@ -64,7 +67,8 @@ "args": { "name": "PROJECT", "isOptional": true, - "template": "folders" + "template": "folders", + "filterTemplateName": "filter-xcodeproj" } }, { @@ -87,7 +91,8 @@ "args": { "name": "PROJECT", "template": "folders", - "isOptional": true + "isOptional": true, + "filterTemplateName": "filter-xcodeproj" } }, { @@ -99,7 +104,8 @@ "description": "The Xcode project document to use", "args": { "name": "PATH", - "template": "folders" + "template": "folders", + "filterTemplateName": "filter-xcodeproj" } } ], diff --git a/command-signatures/json/yarn.json b/command-signatures/json/yarn.json index ffea8e91..4fe75073 100644 --- a/command-signatures/json/yarn.json +++ b/command-signatures/json/yarn.json @@ -2,7 +2,6 @@ "name": "yarn", "description": "Manage packages and run scripts", "generateSpec": "_NuFrRa_(e,n)=>h(void 0,null,function*(){let{script:a,postProcess:t}=R,p=t(yield n(a),e).map(({name:i})=>i).filter(i=>W.includes(i)).map(i=>({name:i===\"@redwoodjs/core\"?[\"redwood\",\"rw\"]:i,loadSpec:i===\"@redwoodjs/core\"?\"redwood\":i,icon:\"fig://icon?type=package\"}));return{name:\"yarn\",subcommands:p}})", - "aliasGenerator": "script_alias", "args": { "name": "script", @@ -495,7 +494,8 @@ "name": "package", "template": "filepaths", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "npms_search" }, "options": [ { @@ -1203,7 +1203,8 @@ "name": "cli", "template": "filepaths", "loadSpec": "_NuFrRa_e=>h(void 0,null,function*(){return{name:\"create-\"+e,type:\"global\"}})", - "isCommand": true + "isCommand": true, + "generatorName": "create_package_search" }, "options": [ { @@ -1499,7 +1500,8 @@ "name": "package", "template": "filepaths", "debounce": true, - "isVariadic": true + "isVariadic": true, + "generatorName": "npms_search" } }, { @@ -4917,7 +4919,6 @@ "name": "workspace", "description": "Manage workspace", "generateSpec": "_NuFrRa_(e,n)=>h(void 0,null,function*(){let t=(yield n(\"yarn --version\")).startsWith(\"1.\"),o=()=>h(void 0,null,function*(){let i=yield n(\"yarn workspaces info\"),s=i.indexOf(\"{\"),r=i.lastIndexOf(\"}\");return Object.entries(JSON.parse(i.slice(s,r+1))).map(([l,{location:f}])=>({name:l,location:f}))}),p=()=>h(void 0,null,function*(){return(yield n(\"yarn workspaces list --json\")).split(`\n`).map(s=>JSON.parse(s.trim()))});try{let s=(t?yield o():yield p()).map(({name:r,location:l})=>({name:r,description:\"Workspaces\",args:{name:\"script\",generators:{cache:{strategy:\"stale-while-revalidate\",ttl:6e4},script:`\\\\cat ${l}/package.json`,postProcess:function(f){if(f.trim()==\"\")return[];try{let A=JSON.parse(f).scripts;if(A)return Object.keys(A).map(G=>({name:G}))}catch(P){}return[]}}}}));return{name:\"workspace\",subcommands:s}}catch(i){console.error(i)}return{name:\"workspaces\"}})", - "args": { "name": "workspace", "description": "Workspace name", diff --git a/command-signatures/json/youtube-dl.json b/command-signatures/json/youtube-dl.json index ec2766a4..9579f882 100644 --- a/command-signatures/json/youtube-dl.json +++ b/command-signatures/json/youtube-dl.json @@ -160,7 +160,8 @@ "description": "Playlist video to start at (default is 1)", "args": { "name": "NUMBER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "flat_playlist" } }, { @@ -168,7 +169,8 @@ "description": "Playlist video to end at (default is last)", "args": { "name": "NUMBER", - "template": "filepaths" + "template": "filepaths", + "generatorName": "flat_playlist" } }, { @@ -176,7 +178,8 @@ "description": "Playlist video to end at (default is last)", "args": { "name": "ITEM_SPEC", - "template": "filepaths" + "template": "filepaths", + "generatorName": "flat_playlist" } }, { diff --git a/command-signatures/src/generators/amplify.rs b/command-signatures/src/generators/amplify.rs index 8920f6ed..b9a84de6 100644 --- a/command-signatures/src/generators/amplify.rs +++ b/command-signatures/src/generators/amplify.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "env_list", Generator::script( CommandBuilder::single_command("amplify env list --json"), - fig_parse::lines, + output_parsers::json_envs, ), ) } diff --git a/command-signatures/src/generators/ansible_doc.rs b/command-signatures/src/generators/ansible_doc.rs index b3ba2235..d2ea4f19 100644 --- a/command-signatures/src/generators/ansible_doc.rs +++ b/command-signatures/src/generators/ansible_doc.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "completions", Generator::script( CommandBuilder::single_command("ansible-doc --list --json 2>/dev/null"), - fig_parse::lines, + output_parsers::json_object_key_descriptions, ), ) } diff --git a/command-signatures/src/generators/ansible_playbook.rs b/command-signatures/src/generators/ansible_playbook.rs new file mode 100644 index 00000000..3d3c41f4 --- /dev/null +++ b/command-signatures/src/generators/ansible_playbook.rs @@ -0,0 +1,7 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("ansible-playbook") + .add_filter("filter-yml-yaml", template_filters::yml_yaml()) +} diff --git a/command-signatures/src/generators/apt.rs b/command-signatures/src/generators/apt.rs index 8680f984..e4199a51 100644 --- a/command-signatures/src/generators/apt.rs +++ b/command-signatures/src/generators/apt.rs @@ -1,5 +1,5 @@ /// Used for debian-based package managers like apt-get, aptitude, etc. -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{ CommandBuilder, CommandSignatureGenerators, Generator, GeneratorResults, GeneratorResultsCollector, Priority, Suggestion, @@ -106,14 +106,21 @@ pub fn generator() -> CommandSignatureGenerators { "list", Generator::script( CommandBuilder::single_command("apt list --installed"), - fig_parse::lines, + output_parsers::apt_package_before_slash, ), ) .add_generator( "list_upgradable", Generator::script( CommandBuilder::single_command("apt list --upgradable"), - fig_parse::lines, + output_parsers::apt_package_before_slash, + ), + ) + .add_generator( + "list_prefix", + Generator::command_from_tokens( + super::fig_token::apt_list_prefix, + output_parsers::lines, ), ) } diff --git a/command-signatures/src/generators/assimp.rs b/command-signatures/src/generators/assimp.rs index 486e69d2..3252d7aa 100644 --- a/command-signatures/src/generators/assimp.rs +++ b/command-signatures/src/generators/assimp.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "listexport", Generator::script( CommandBuilder::single_command("assimp listexport"), - fig_parse::lines, + output_parsers::desc_extension, ), ) .add_generator( "listext", Generator::script( CommandBuilder::single_command("assimp listext"), - fig_parse::lines, + output_parsers::desc_extension, ), ) } diff --git a/command-signatures/src/generators/autojump.rs b/command-signatures/src/generators/autojump.rs index a5aa91d0..b9027da1 100644 --- a/command-signatures/src/generators/autojump.rs +++ b/command-signatures/src/generators/autojump.rs @@ -1,12 +1,14 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("autojump").add_generator( + CommandSignatureGenerators::new("j").add_generator( "cat", Generator::script( - CommandBuilder::single_command(r#"cat "$HOME"/Library/autojump/autojump.txt"#), - fig_parse::lines, + CommandBuilder::single_command( + r#"cat "$HOME/Library/autojump/autojump.txt" "$HOME/.local/share/autojump/autojump.txt" 2>/dev/null"#, + ), + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/bat.rs b/command-signatures/src/generators/bat.rs index 95a884fe..0296fd9b 100644 --- a/command-signatures/src/generators/bat.rs +++ b/command-signatures/src/generators/bat.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "completions", Generator::script( CommandBuilder::single_command("bat --list-themes"), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( "completions_bat", Generator::script( CommandBuilder::single_command("bat --list-languages"), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( @@ -23,7 +23,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "bat --paging unknow 2>&1 >/dev/null | grep possible", ), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( @@ -32,7 +32,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "bat --decorations unknow 2>&1 >/dev/null | grep possible", ), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( @@ -41,7 +41,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "bat --color unknow 2>&1 >/dev/null | grep possible", ), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( @@ -50,7 +50,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "bat --italic-text unknow 2>&1 >/dev/null | grep possible", ), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( @@ -59,7 +59,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "bat --wrap unknow 2>&1 >/dev/null | grep possible", ), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/black.rs b/command-signatures/src/generators/black.rs index 1de6a599..b5061b3f 100644 --- a/command-signatures/src/generators/black.rs +++ b/command-signatures/src/generators/black.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "gh_release_list_psf_black", Generator::script( CommandBuilder::single_command("gh release list --repo psf/black"), - fig_parse::lines, + output_parsers::desc_version, ), ) } diff --git a/command-signatures/src/generators/brew.rs b/command-signatures/src/generators/brew.rs index 434491f5..4a8450cc 100644 --- a/command-signatures/src/generators/brew.rs +++ b/command-signatures/src/generators/brew.rs @@ -94,6 +94,10 @@ pub fn generator() -> CommandSignatureGenerators { "repositories_generator", Generator::script(CommandBuilder::single_command("brew tap"), post_process), ) + .add_generator( + "gist_logs_actions", + Generator::command_from_tokens(super::fig_token::brew_gist_logs_actions, post_process), + ) } fn post_process(output: &str) -> GeneratorResults { diff --git a/command-signatures/src/generators/bun.rs b/command-signatures/src/generators/bun.rs index 87348ebf..1ca2e062 100644 --- a/command-signatures/src/generators/bun.rs +++ b/command-signatures/src/generators/bun.rs @@ -6,6 +6,13 @@ pub fn generator() -> CommandSignatureGenerators { CommandSignatureGenerators::new("bun") .add_generator("get_scripts_generator", get_scripts_generator()) .add_generator("dependencies_generator", dependencies_generator()) + .add_generator( + "npms_search", + warp_completion_metadata::Generator::command_from_tokens( + crate::generators::fig_token::npms_search, + crate::generators::output_parsers::npms_search_results, + ), + ) } #[cfg(test)] diff --git a/command-signatures/src/generators/cargo.rs b/command-signatures/src/generators/cargo.rs index f3286364..80bf5d9b 100644 --- a/command-signatures/src/generators/cargo.rs +++ b/command-signatures/src/generators/cargo.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::{fig_token, output_parsers, template_filters}; use std::collections::{HashMap, HashSet}; use warp_completion_metadata::{ @@ -112,28 +112,14 @@ pub fn generator() -> CommandSignatureGenerators { "bin_list", Generator::script( CommandBuilder::single_command("cargo metadata --no-deps --format-version 1"), - |output| { - let metadata: Result = serde_json::from_str(output); - - match metadata { - Ok(metadata) => metadata - .packages - .into_iter() - .flat_map(|package| package.targets.into_iter().flatten()) - .filter_map(|target| { - target - .kind - .into_iter() - .any(|item| item == "bin") - .then(|| Suggestion::new(target.name)) - }) - .collect_unordered_results(), - Err(e) => { - log::error!("Couldn't parse cargo metadata with error {}", e); - GeneratorResults::default() - } - } - }, + |output| metadata_targets_of_kind(output, "bin"), + ), + ) + .add_generator( + "test_targets", + Generator::script( + CommandBuilder::single_command("cargo metadata --no-deps --format-version 1"), + |output| metadata_targets_of_kind(output, "test"), ), ) .add_generator( @@ -157,7 +143,38 @@ pub fn generator() -> CommandSignatureGenerators { "read_manifest", Generator::script( CommandBuilder::single_command("cargo read-manifest"), - fig_parse::lines, + output_parsers::cargo_read_manifest_bins, ), ) + .add_generator( + "crates_io_search", + Generator::command_from_tokens( + fig_token::crates_io_search, + output_parsers::json_crates, + ), + ) + .add_generator( + "test_list", + Generator::command_from_tokens(fig_token::cargo_test_list, output_parsers::named_lines), + ) + .add_filter("filter-cargo-toml", template_filters::cargo_toml()) + .add_filter("filter-cargo-lock", template_filters::cargo_lock()) + .add_filter("filter-rustfmt-toml", template_filters::rustfmt_toml()) + .add_filter("filter-rs", template_filters::rs()) +} + +fn metadata_targets_of_kind(output: &str, kind: &str) -> GeneratorResults { + match serde_json::from_str::(output) { + Ok(metadata) => metadata + .packages + .into_iter() + .flat_map(|package| package.targets.into_iter().flatten()) + .filter(|target| target.kind.iter().any(|item| item == kind)) + .map(|target| Suggestion::new(target.name)) + .collect_unordered_results(), + Err(e) => { + log::error!("Couldn't parse cargo metadata with error {e}"); + GeneratorResults::default() + } + } } diff --git a/command-signatures/src/generators/checkov.rs b/command-signatures/src/generators/checkov.rs index e9fa8024..7651f04a 100644 --- a/command-signatures/src/generators/checkov.rs +++ b/command-signatures/src/generators/checkov.rs @@ -1,4 +1,3 @@ -use super::fig_parse; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +5,7 @@ pub fn generator() -> CommandSignatureGenerators { "git_branch", Generator::script( CommandBuilder::single_command("git branch --no-color"), - fig_parse::lines, + crate::generators::git::post_process_branches, ), ) } diff --git a/command-signatures/src/generators/chown.rs b/command-signatures/src/generators/chown.rs new file mode 100644 index 00000000..070ce7a2 --- /dev/null +++ b/command-signatures/src/generators/chown.rs @@ -0,0 +1,9 @@ +use super::{fig_token, output_parsers}; +use warp_completion_metadata::{CommandSignatureGenerators, Generator}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("chown").add_generator( + "users_or_groups", + Generator::command_from_tokens(fig_token::chown_dscl, output_parsers::lines), + ) +} diff --git a/command-signatures/src/generators/cloudflared.rs b/command-signatures/src/generators/cloudflared.rs new file mode 100644 index 00000000..1ac4003e --- /dev/null +++ b/command-signatures/src/generators/cloudflared.rs @@ -0,0 +1,7 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("cloudflared") + .add_filter("filter-yml-yaml", template_filters::yml_yaml()) +} diff --git a/command-signatures/src/generators/cmd_n.rs b/command-signatures/src/generators/cmd_n.rs index 0e1783c3..8db711e3 100644 --- a/command-signatures/src/generators/cmd_n.rs +++ b/command-signatures/src/generators/cmd_n.rs @@ -1,12 +1,14 @@ -use super::fig_parse; +use super::{output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("n").add_generator( - "lsr", - Generator::script( - CommandBuilder::single_command("n lsr --all"), - fig_parse::lines, - ), - ) + CommandSignatureGenerators::new("n") + .add_generator( + "lsr", + Generator::script( + CommandBuilder::single_command("n lsr --all"), + output_parsers::slice2_reversed, + ), + ) + .add_filter("filter-js-ts-family", template_filters::js_ts_family()) } diff --git a/command-signatures/src/generators/copilot.rs b/command-signatures/src/generators/copilot.rs index 24875e83..0fddc183 100644 --- a/command-signatures/src/generators/copilot.rs +++ b/command-signatures/src/generators/copilot.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "cat_copilot_workspace", Generator::script( CommandBuilder::single_command("cat copilot/.workspace"), - fig_parse::lines, + output_parsers::yaml_application, ), ) } diff --git a/command-signatures/src/generators/cordova.rs b/command-signatures/src/generators/cordova.rs index 6c03ae20..a49e7e61 100644 --- a/command-signatures/src/generators/cordova.rs +++ b/command-signatures/src/generators/cordova.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "cat_package_json", Generator::script( CommandBuilder::single_command("cat package.json"), - fig_parse::lines, + output_parsers::json_cordova_platforms, ), ) .add_generator( "plugin_list", Generator::script( CommandBuilder::single_command("cordova plugin list"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/dd.rs b/command-signatures/src/generators/dd.rs new file mode 100644 index 00000000..c716bb74 --- /dev/null +++ b/command-signatures/src/generators/dd.rs @@ -0,0 +1,9 @@ +use super::{fig_token, output_parsers}; +use warp_completion_metadata::{CommandSignatureGenerators, Generator}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("dd").add_generator( + "conv_remaining", + Generator::command_from_tokens(fig_token::dd_conv_remaining, output_parsers::lines), + ) +} diff --git a/command-signatures/src/generators/degit.rs b/command-signatures/src/generators/degit.rs new file mode 100644 index 00000000..14dfbd15 --- /dev/null +++ b/command-signatures/src/generators/degit.rs @@ -0,0 +1,12 @@ +use super::{fig_token, output_parsers}; +use warp_completion_metadata::{CommandSignatureGenerators, Generator}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("degit").add_generator( + "github_user_repos", + Generator::command_from_tokens( + fig_token::github_user_repos, + output_parsers::github_repos_json, + ), + ) +} diff --git a/command-signatures/src/generators/deno.rs b/command-signatures/src/generators/deno.rs index 7456dac2..c579b60b 100644 --- a/command-signatures/src/generators/deno.rs +++ b/command-signatures/src/generators/deno.rs @@ -1,29 +1,36 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { CommandSignatureGenerators::new("deno") .add_generator( - "curl_https_cdn_deno_land_deno_meta_versions_json", + "deno_versions", Generator::script( CommandBuilder::single_command( "curl -sL 'https://cdn.deno.land/deno/meta/versions.json'", ), - fig_parse::lines, + output_parsers::json_string_array, ), ) .add_generator( - "find_deno_bin_1_f", + "deno_binaries", Generator::script( CommandBuilder::single_command(r"\find ~/.deno/bin -maxdepth 1 -perm -111 -type f"), - fig_parse::lines, + output_parsers::deno_binaries, ), ) .add_generator( "lint", Generator::script( CommandBuilder::single_command("deno lint --rules --json"), - fig_parse::lines, + output_parsers::json_deno_codes, + ), + ) + .add_generator( + "doc_json", + Generator::command_from_tokens( + super::fig_token::deno_doc_json, + output_parsers::json_deno_doc_nodes, ), ) } diff --git a/command-signatures/src/generators/deployctl.rs b/command-signatures/src/generators/deployctl.rs index e2772b4d..2921415f 100644 --- a/command-signatures/src/generators/deployctl.rs +++ b/command-signatures/src/generators/deployctl.rs @@ -1,14 +1,16 @@ -use super::fig_parse; +use super::{output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("deployctl").add_generator( - "curl_https_cdn_deno_land_deploy_meta_versions_json", - Generator::script( - CommandBuilder::single_command( - "curl -sL 'https://cdn.deno.land/deploy/meta/versions.json'", + CommandSignatureGenerators::new("deployctl") + .add_generator( + "deploy_versions", + Generator::script( + CommandBuilder::single_command( + "curl -sL 'https://cdn.deno.land/deploy/meta/versions.json'", + ), + output_parsers::json_string_array, ), - fig_parse::lines, - ), - ) + ) + .add_filter("filter-deployctl", template_filters::deployctl()) } diff --git a/command-signatures/src/generators/deta.rs b/command-signatures/src/generators/deta.rs index 69c0a68a..0d32b58b 100644 --- a/command-signatures/src/generators/deta.rs +++ b/command-signatures/src/generators/deta.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "node12_node14_python3_7_python3", Generator::script( CommandBuilder::single_command("echo node12, node14, python3.7, python3.9"), - fig_parse::lines, + output_parsers::desc_runtime, ), ) } diff --git a/command-signatures/src/generators/direnv.rs b/command-signatures/src/generators/direnv.rs new file mode 100644 index 00000000..a8c2cb09 --- /dev/null +++ b/command-signatures/src/generators/direnv.rs @@ -0,0 +1,6 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("direnv").add_filter("filter-envrc", template_filters::envrc()) +} diff --git a/command-signatures/src/generators/docker.rs b/command-signatures/src/generators/docker.rs index e29e059e..194c60cf 100644 --- a/command-signatures/src/generators/docker.rs +++ b/command-signatures/src/generators/docker.rs @@ -483,4 +483,15 @@ pub fn generator() -> CommandSignatureGenerators { .then_some(suggestion) }), ) + .add_generator( + "from_as", + Generator::command_from_tokens(super::fig_token::docker_from_as, super::output_parsers::docker_from_as_names), + ) + .add_generator( + "search", + Generator::command_from_tokens( + super::fig_token::docker_search, + super::output_parsers::docker_search_names, + ), + ) } diff --git a/command-signatures/src/generators/dtm.rs b/command-signatures/src/generators/dtm.rs index 4514c617..229980c7 100644 --- a/command-signatures/src/generators/dtm.rs +++ b/command-signatures/src/generators/dtm.rs @@ -1,12 +1,14 @@ -use super::fig_parse; +use super::{output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("dtm").add_generator( - "list_plugins", - Generator::script( - CommandBuilder::single_command("dtm list plugins"), - fig_parse::lines, - ), - ) + CommandSignatureGenerators::new("dtm") + .add_generator( + "list_plugins", + Generator::script( + CommandBuilder::single_command("dtm list plugins"), + output_parsers::desc_plugin, + ), + ) + .add_filter("filter-yml-yaml", template_filters::yml_yaml()) } diff --git a/command-signatures/src/generators/eb.rs b/command-signatures/src/generators/eb.rs index c5ea95c0..f36835d4 100644 --- a/command-signatures/src/generators/eb.rs +++ b/command-signatures/src/generators/eb.rs @@ -1,9 +1,12 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { CommandSignatureGenerators::new("eb").add_generator( "list", - Generator::script(CommandBuilder::single_command("eb list"), fig_parse::lines), + Generator::script( + CommandBuilder::single_command("eb list"), + output_parsers::strip_star_prefix, + ), ) } diff --git a/command-signatures/src/generators/elixir.rs b/command-signatures/src/generators/elixir.rs new file mode 100644 index 00000000..53ba7b7a --- /dev/null +++ b/command-signatures/src/generators/elixir.rs @@ -0,0 +1,6 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("elixir").add_filter("filter-exs", template_filters::exs()) +} diff --git a/command-signatures/src/generators/elm.rs b/command-signatures/src/generators/elm.rs index b4d69344..f12ab59f 100644 --- a/command-signatures/src/generators/elm.rs +++ b/command-signatures/src/generators/elm.rs @@ -1,13 +1,13 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { CommandSignatureGenerators::new("elm") .add_generator( - "curl_accept_encoding_gzip_https_package_elm_lang_org_search_json", + "elm_packages", Generator::script( CommandBuilder::single_command("curl -sH 'accept-encoding: gzip' https://package.elm-lang.org/search.json | gunzip"), - fig_parse::lines, + output_parsers::json_name_summary, ), ) } diff --git a/command-signatures/src/generators/elm_review.rs b/command-signatures/src/generators/elm_review.rs index 6a59617d..0d690c96 100644 --- a/command-signatures/src/generators/elm_review.rs +++ b/command-signatures/src/generators/elm_review.rs @@ -1,9 +1,12 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { CommandSignatureGenerators::new("elm-review").add_generator( "echo", - Generator::script(CommandBuilder::single_command("echo"), fig_parse::lines), + Generator::script( + CommandBuilder::single_command("echo"), + output_parsers::named_lines, + ), ) } diff --git a/command-signatures/src/generators/esbuild.rs b/command-signatures/src/generators/esbuild.rs new file mode 100644 index 00000000..6da89fad --- /dev/null +++ b/command-signatures/src/generators/esbuild.rs @@ -0,0 +1,9 @@ +use super::{fig_token, output_parsers}; +use warp_completion_metadata::{CommandSignatureGenerators, Generator}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("esbuild").add_generator( + "loader", + Generator::command_from_tokens(fig_token::esbuild_loader, output_parsers::lines), + ) +} diff --git a/command-signatures/src/generators/eslint.rs b/command-signatures/src/generators/eslint.rs index ba6a1f03..982ec3dd 100644 --- a/command-signatures/src/generators/eslint.rs +++ b/command-signatures/src/generators/eslint.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,7 +7,11 @@ pub fn generator() -> CommandSignatureGenerators { "ls_node_modules_root_global", Generator::script( CommandBuilder::single_command("{ ls node_modules ; ls $(npm root -g) ; ls $(yarn global dir)/node_modules/ ; } | cat"), - fig_parse::lines, + output_parsers::eslint_plugin_names, ), ) + .add_generator( + "env_remaining", + Generator::command_from_tokens(super::fig_token::eslint_env_remaining, output_parsers::named_lines), + ) } diff --git a/command-signatures/src/generators/expo.rs b/command-signatures/src/generators/expo.rs index ed6d04ce..0785a517 100644 --- a/command-signatures/src/generators/expo.rs +++ b/command-signatures/src/generators/expo.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,21 +7,28 @@ pub fn generator() -> CommandSignatureGenerators { "sysctl_hw_ncpu", Generator::script( CommandBuilder::single_command("sysctl -n hw.ncpu"), - fig_parse::lines, + output_parsers::descending_count, ), ) .add_generator( "xcodebuild_ios_xcodeproj", Generator::script( CommandBuilder::single_command("xcodebuild -project ios/*.xcodeproj -list -json"), - fig_parse::lines, + output_parsers::json_string_array, ), ) .add_generator( "xcrun_xctrace_list_devices", Generator::script( CommandBuilder::single_command("xcrun xctrace list devices"), - fig_parse::lines, + output_parsers::second_whitespace_token, + ), + ) + .add_generator( + "npms_search", + Generator::command_from_tokens( + super::fig_token::npms_search, + output_parsers::npms_search_results, ), ) } diff --git a/command-signatures/src/generators/expo_cli.rs b/command-signatures/src/generators/expo_cli.rs index 8bc629ce..37928f1c 100644 --- a/command-signatures/src/generators/expo_cli.rs +++ b/command-signatures/src/generators/expo_cli.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,21 +7,28 @@ pub fn generator() -> CommandSignatureGenerators { "sysctl_hw_ncpu", Generator::script( CommandBuilder::single_command("sysctl -n hw.ncpu"), - fig_parse::lines, + output_parsers::descending_count, ), ) .add_generator( "xcodebuild_ios_xcodeproj", Generator::script( CommandBuilder::single_command("xcodebuild -project ios/*.xcodeproj -list -json"), - fig_parse::lines, + output_parsers::json_string_array, ), ) .add_generator( "xcrun_xctrace_list_devices", Generator::script( CommandBuilder::single_command("xcrun xctrace list devices"), - fig_parse::lines, + output_parsers::second_whitespace_token, + ), + ) + .add_generator( + "npms_search", + Generator::command_from_tokens( + super::fig_token::npms_search, + output_parsers::npms_search_results, ), ) } diff --git a/command-signatures/src/generators/ffmpeg.rs b/command-signatures/src/generators/ffmpeg.rs index 9c7b30f4..f73f6aea 100644 --- a/command-signatures/src/generators/ffmpeg.rs +++ b/command-signatures/src/generators/ffmpeg.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "completions", Generator::script( CommandBuilder::single_command("ffmpeg -codecs"), - fig_parse::lines, + output_parsers::second_whitespace_token, ), ) .add_generator( "completions_devices", Generator::script( CommandBuilder::single_command("ffmpeg -devices"), - fig_parse::lines, + output_parsers::second_whitespace_token, ), ) } diff --git a/command-signatures/src/generators/fig_parse.rs b/command-signatures/src/generators/fig_parse.rs deleted file mode 100644 index 5685baa5..00000000 --- a/command-signatures/src/generators/fig_parse.rs +++ /dev/null @@ -1,11 +0,0 @@ -use warp_completion_metadata::{GeneratorResults, GeneratorResultsCollector, Suggestion}; - -/// One suggestion per non-empty trimmed line. -pub fn lines(output: &str) -> GeneratorResults { - output - .lines() - .map(str::trim) - .filter(|line| !line.is_empty()) - .map(Suggestion::new) - .collect_unordered_results() -} diff --git a/command-signatures/src/generators/fig_teams.rs b/command-signatures/src/generators/fig_teams.rs new file mode 100644 index 00000000..a2d18b0c --- /dev/null +++ b/command-signatures/src/generators/fig_teams.rs @@ -0,0 +1,41 @@ +use super::output_parsers; +use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("fig-teams@latest") + .add_generator( + "teams_list", + Generator::script( + CommandBuilder::single_command("npx -y fig-teams@latest teams ls --json"), + output_parsers::json_string_array, + ), + ) + .add_generator( + "users_for_selected_team", + Generator::command_from_tokens( + users_for_selected_team, + output_parsers::json_string_array, + ), + ) +} + +fn users_for_selected_team(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let team = tokens.iter().enumerate().find_map(|(i, token)| { + if (*token == "-t" || *token == "--team") && i + 1 < tokens.len() { + Some(tokens[i + 1]) + } else { + None + } + }); + match team { + Some(team) if !team.is_empty() => CommandBuilder::single_command(format!( + "npx -y fig-teams@latest users get -t {} --json", + shell_single_quote(team) + )), + _ => CommandBuilder::single_command("true"), + } +} + +fn shell_single_quote(value: &str) -> String { + format!("'{}'", value.replace('\'', r"'\''")) +} diff --git a/command-signatures/src/generators/fig_teams_latest.rs b/command-signatures/src/generators/fig_teams_latest.rs deleted file mode 100644 index 1311ec46..00000000 --- a/command-signatures/src/generators/fig_teams_latest.rs +++ /dev/null @@ -1,12 +0,0 @@ -use super::fig_parse; -use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; - -pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("fig-teams@latest").add_generator( - "npx_fig_teams_latest_teams", - Generator::script( - CommandBuilder::single_command("npx -y fig-teams@latest teams ls --json"), - fig_parse::lines, - ), - ) -} diff --git a/command-signatures/src/generators/fig_token.rs b/command-signatures/src/generators/fig_token.rs new file mode 100644 index 00000000..6f20f002 --- /dev/null +++ b/command-signatures/src/generators/fig_token.rs @@ -0,0 +1,484 @@ +use warp_completion_metadata::CommandBuilder; + +pub fn npms_search(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + curl_npms(last_token(tokens), "") +} + +pub fn npms_search_create_prefix(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let q = last_token(tokens); + if q.is_empty() { + CommandBuilder::single_command("true") + } else { + curl_npms(&format!("create-{q}"), "") + } +} + +pub fn crates_io_search(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let q = last_token(tokens); + if q.is_empty() { + CommandBuilder::single_command("true") + } else { + CommandBuilder::single_command(format!( + "curl -sfL 'https://crates.io/api/v1/crates?q={}&per_page=60'", + urlencode(q) + )) + } +} + +pub fn trivy_severity_remaining(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + remaining_csv(tokens, &["UNKNOWN", "LOW", "MEDIUM", "HIGH", "CRITICAL"]) +} + +pub fn trivy_scanners_remaining(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + remaining_csv(tokens, &["vuln", "config"]) +} + +pub fn trivy_pkg_types_remaining(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + remaining_csv(tokens, &["os", "library"]) +} + +pub fn docker_from_as(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + if let Some(i) = tokens.iter().position(|t| *t == "-f" || *t == "--file") { + if let Some(file) = tokens.get(i + 1) { + return CommandBuilder::single_command(format!( + r#"grep -iE 'FROM.*AS' {} 2>/dev/null"#, + shell_single_quote(file), + )); + } + } + CommandBuilder::single_command(r#"grep -iE 'FROM.*AS' "$PWD/Dockerfile" 2>/dev/null"#) +} + +pub fn docker_search(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let q = last_token(tokens); + if q.is_empty() { + CommandBuilder::single_command("true") + } else { + CommandBuilder::single_command(format!( + "docker search {} --format '{{{{ json . }}}}'", + shell_single_quote(q) + )) + } +} + +pub fn gh_repo_list_for_owner(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let token = last_token(tokens); + let owner = token.split('/').next().unwrap_or(""); + if owner.is_empty() { + CommandBuilder::single_command("true") + } else { + CommandBuilder::single_command(format!( + "gh repo list {} --limit 9999 --json nameWithOwner,description", + shell_single_quote(owner) + )) + } +} + +pub fn apt_list_prefix(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let q = last_token(tokens); + if q.is_empty() { + CommandBuilder::single_command("true") + } else { + CommandBuilder::single_command(format!( + r#"apt list 2>/dev/null | awk -F/ -v p={} '$1 ~ "^"p {{ print $1 }}'"#, + shell_single_quote(®ex_escape(q)) + )) + } +} + +pub fn cargo_test_list( + tokens: &[&str], + has_trailing_whitespace: bool, + _: &[String], +) -> CommandBuilder { + let token = if has_trailing_whitespace { + "" + } else { + last_token(tokens) + }; + let token = if token.starts_with('-') { "" } else { token }; + let segments = token.split("::").filter(|s| !s.is_empty()).count(); + let depth = if token.ends_with("::") { + segments + 1 + } else { + segments.max(1) + }; + CommandBuilder::single_command(format!( + r#"cargo t -- --list 2>/dev/null | awk '/: test$/ {{ print substr($1, 1, length($1) - 1) }}' | awk -F '::' -v n={depth} '{{ s=$1; for (i=2; i<=n && i<=NF; i++) s=s "::" $i; print s }}' | grep -F {query} | sort -u"#, + depth = depth, + query = shell_single_quote(token) + )) +} + +pub fn chown_dscl(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let last = last_token(tokens); + if let Some((user, _)) = last.split_once(':') { + let prefix = format!("{user}:"); + CommandBuilder::single_command(format!( + r#"{{ getent group 2>/dev/null | cut -d: -f1; dscl . -list /Groups PrimaryGroupID 2>/dev/null | awk '{{print $1}}'; }} | awk -v p={} 'NF && !seen[$0]++ {{ print p $0 }}'"#, + shell_single_quote(&prefix) + )) + } else { + CommandBuilder::single_command( + r#"{ getent passwd 2>/dev/null | cut -d: -f1; dscl . -list /Users UniqueID 2>/dev/null | awk '{print $1}'; } | awk 'NF && !seen[$0]++'"#, + ) + } +} + +pub fn nx_list(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let last = last_token(tokens); + if last.contains(':') { + let project = last.split(':').next().unwrap_or(""); + CommandBuilder::single_command(format!("nx list {}", shell_single_quote(project))) + } else { + CommandBuilder::single_command("nx list") + } +} + +pub fn youtube_dl_flat_playlist(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let urls: Vec<_> = tokens + .iter() + .copied() + .filter(|t| t.contains("youtube.")) + .map(shell_single_quote) + .collect(); + if urls.is_empty() { + CommandBuilder::single_command("true") + } else { + CommandBuilder::single_command(format!("youtube-dl --flat-playlist -J {}", urls.join(" "))) + } +} + +pub fn deno_doc_json( + tokens: &[&str], + has_trailing_whitespace: bool, + _: &[String], +) -> CommandBuilder { + let keep = ["--private", "--builtin", "--unstable"]; + let complete = if has_trailing_whitespace || tokens.len() <= 1 { + tokens + } else { + &tokens[..tokens.len() - 1] + }; + let mut args: Vec = complete + .iter() + .copied() + .filter(|t| { + !t.is_empty() + && (!t.starts_with('-') || keep.contains(t)) + && !t.starts_with('$') + && !t.starts_with('(') + }) + .map(shell_single_quote) + .collect(); + if args.is_empty() { + return CommandBuilder::single_command("true"); + } + args.push("--json".to_string()); + CommandBuilder::single_command(args.join(" ")) +} + +pub fn git_status_staged_or_unstaged(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + if tokens.contains(&"--staged") || tokens.contains(&"--cached") { + CommandBuilder::single_command( + "git --no-optional-locks status --short | sed -ne '/^M /p' -e '/A /p'", + ) + } else { + CommandBuilder::single_command( + "git --no-optional-locks status --short | sed -ne '/M /p' -e '/A /p'", + ) + } +} + +pub fn eslint_env_remaining(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + remaining_csv( + tokens, + &[ + "browser", + "node", + "commonjs", + "shared-node-browser", + "es6", + "es2017", + "es2020", + "es2021", + "worker", + "amd", + "mocha", + "jasmine", + "jest", + "phantomjs", + "protractor", + "qunit", + "jquery", + "prototypejs", + "shelljs", + "meteor", + "mongo", + "applescript", + "nashorn", + "serviceworker", + "atomtest", + "embertest", + "webextensions", + "greasemonkey", + ], + ) +} + +pub fn brew_gist_logs_actions(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let has_non_flag = tokens + .iter() + .skip(2) + .any(|t| !t.starts_with('-') && !t.is_empty()); + if has_non_flag { + remaining_csv(tokens, &["install", "install-on-request", "build-error"]) + } else { + remaining_csv(tokens, &["cask-install", "os-version"]) + } +} + +pub fn known_hosts_file( + tokens: &[&str], + has_trailing_whitespace: bool, + _: &[String], +) -> CommandBuilder { + let last = if has_trailing_whitespace { + "" + } else { + last_token(tokens) + }; + let prefix = user_at_prefix(last); + if prefix.is_empty() { + CommandBuilder::single_command("cat ~/.ssh/known_hosts") + } else { + CommandBuilder::single_command(format!( + "printf '%s\\n' {}; cat ~/.ssh/known_hosts", + shell_single_quote(&format!("WARP_SSH_USER_PREFIX={prefix}")) + )) + } +} + +pub fn github_user_repos(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let last = last_token(tokens); + if last.contains(':') || !last.contains('/') { + return CommandBuilder::single_command("true"); + } + let user = last.split('/').next().unwrap_or(""); + if user.is_empty() { + CommandBuilder::single_command("true") + } else { + CommandBuilder::single_command(format!( + "curl -sL 'https://api.github.com/users/{}/repos'", + urlencode(user) + )) + } +} + +pub fn git_flow_type_branches(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let kind = tokens.get(1).copied().unwrap_or(""); + if kind.is_empty() || !kind.chars().all(|c| c.is_ascii_alphanumeric() || c == '-') { + return CommandBuilder::single_command("true"); + } + CommandBuilder::single_command(format!( + r#"p=$(git config --get gitflow.prefix.{kind} 2>/dev/null); git --no-optional-locks branch -a --no-color --sort=-committerdate | sed 's/^[*+] //; s/^ //' | awk -v p="$p" 'index($0,p)==1 {{ print substr($0,length(p)+1) }}'"# + )) +} + +pub fn dd_conv_remaining(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + remaining_csv( + tokens, + &[ + "ascii", + "oldascii", + "block", + "ebcdic", + "ibm", + "oldebcdic", + "oldibm", + "lcase", + "noerror", + "notrunc", + "osync", + "sparse", + "swab", + "sync", + "ucase", + "unblock", + ], + ) +} + +pub fn man_sections_remaining(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + remaining_delimited(tokens, &["1", "2", "3", "4", "5", "6", "7", "8"], ':') +} + +pub fn file_param_keys(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let last = last_token(tokens); + if last.contains('=') { + CommandBuilder::single_command("true") + } else { + remaining_delimited( + tokens, + &[ + "bytes", + "elf_notes", + "elf_phum", + "encoding", + "indir", + "name", + "regex", + ], + ',', + ) + } +} + +pub fn robot_variables(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + if last_token(tokens).contains(':') { + CommandBuilder::single_command("true") + } else { + CommandBuilder::single_command( + r#"for i in $(find -E . -regex ".*.(robot|resource)" -type f); do cat -s $i ; done"#, + ) + } +} + +pub fn scc_output_paths(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + remaining_csv( + tokens, + &[ + "tabular", + "wide", + "json", + "csv", + "csv-stream", + "cloc-yaml", + "html", + "html-table", + "sql", + "sql-insert", + ], + ) +} + +pub fn esbuild_loader(tokens: &[&str], _: bool, _: &[String]) -> CommandBuilder { + let last = last_token(tokens); + if last.contains(':') || last == "--loader" || last == "--banner" { + remaining_delimited( + tokens, + &[ + "js", "jsx", "ts", "tsx", "css", "json", "text", "base64", "file", "dataurl", + "binary", "copy", + ], + ':', + ) + } else { + CommandBuilder::single_command( + "find . -type f -name '*.*' ! -path '*/node_modules/*' | sed 's/.*\\.//' | sort -u", + ) + } +} + +fn curl_npms(query: &str, _: &str) -> CommandBuilder { + if query.is_empty() { + CommandBuilder::single_command("true") + } else { + CommandBuilder::single_command(format!( + "curl -s -H 'Accept: application/json' 'https://api.npms.io/v2/search?size=20&q={}'", + urlencode(query) + )) + } +} + +fn remaining_csv(tokens: &[&str], options: &[&str]) -> CommandBuilder { + remaining_delimited(tokens, options, ',') +} + +fn remaining_delimited(tokens: &[&str], options: &[&str], delimiter: char) -> CommandBuilder { + let last = last_token(tokens); + let (insert_prefix, csv) = last + .rsplit_once('=') + .filter(|(head, _)| { + !head.is_empty() + && !head.contains(delimiter) + && head + .chars() + .all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_')) + }) + .map(|(head, rest)| (format!("{head}="), rest)) + .unwrap_or_else(|| (String::new(), last)); + let ends_with_delim = csv.ends_with(delimiter); + let mut parts: Vec<&str> = csv.split(delimiter).filter(|s| !s.is_empty()).collect(); + if !csv.is_empty() && !ends_with_delim { + parts.pop(); + } + let used: std::collections::HashSet<&str> = parts.iter().copied().collect(); + let left: Vec<&str> = options + .iter() + .copied() + .filter(|o| !used.contains(o)) + .collect(); + if left.is_empty() { + return CommandBuilder::single_command("true"); + } + let already = if parts.is_empty() { + insert_prefix + } else { + format!( + "{insert_prefix}{}{delimiter}", + parts.join(&delimiter.to_string()) + ) + }; + let rendered: Vec = left + .iter() + .map(|option| format!("{already}{option}")) + .collect(); + CommandBuilder::single_command(format!("printf '%s\\n' {}", rendered.join(" "))) +} + +fn user_at_prefix(token: &str) -> String { + let Some((user, _)) = token.split_once('@') else { + return String::new(); + }; + if user.is_empty() + || !user + .chars() + .all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-')) + { + return String::new(); + } + format!("{user}@") +} + +fn last_token<'a>(tokens: &[&'a str]) -> &'a str { + tokens.last().copied().unwrap_or("") +} + +fn shell_single_quote(value: &str) -> String { + format!("'{}'", value.replace('\'', r"'\''")) +} + +fn regex_escape(value: &str) -> String { + let mut out = String::new(); + for c in value.chars() { + if "^$.*+?()[]{}|\\".contains(c) { + out.push('\\'); + } + out.push(c); + } + out +} + +fn urlencode(value: &str) -> String { + let mut out = String::new(); + for b in value.as_bytes() { + match b { + b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => { + out.push(*b as char); + } + _ => out.push_str(&format!("%{b:02X}")), + } + } + out +} diff --git a/command-signatures/src/generators/file.rs b/command-signatures/src/generators/file.rs new file mode 100644 index 00000000..ab848552 --- /dev/null +++ b/command-signatures/src/generators/file.rs @@ -0,0 +1,9 @@ +use super::{fig_token, output_parsers}; +use warp_completion_metadata::{CommandSignatureGenerators, Generator}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("file").add_generator( + "param_keys", + Generator::command_from_tokens(fig_token::file_param_keys, output_parsers::lines), + ) +} diff --git a/command-signatures/src/generators/fisher.rs b/command-signatures/src/generators/fisher.rs index d2613619..d56a525d 100644 --- a/command-signatures/src/generators/fisher.rs +++ b/command-signatures/src/generators/fisher.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "fish_fisher_list", Generator::script( CommandBuilder::single_command("fish -c 'fisher list'"), - fig_parse::lines, + output_parsers::desc_plugin, ), ) } diff --git a/command-signatures/src/generators/fly.rs b/command-signatures/src/generators/fly.rs index a829bd4b..814074e0 100644 --- a/command-signatures/src/generators/fly.rs +++ b/command-signatures/src/generators/fly.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "flyctl_list_apps", Generator::script( CommandBuilder::single_command("flyctl list apps"), - fig_parse::lines, + output_parsers::pipe_table_name_col1_desc, ), ) .add_generator( "flyctl_list_orgs", Generator::script( CommandBuilder::single_command("flyctl list orgs"), - fig_parse::lines, + output_parsers::pipe_table_name_col1_desc, ), ) } diff --git a/command-signatures/src/generators/flyctl.rs b/command-signatures/src/generators/flyctl.rs index 423f0cc0..9791686f 100644 --- a/command-signatures/src/generators/flyctl.rs +++ b/command-signatures/src/generators/flyctl.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "list_apps", Generator::script( CommandBuilder::single_command("flyctl list apps"), - fig_parse::lines, + output_parsers::pipe_table_name_col1_desc, ), ) .add_generator( "list_orgs", Generator::script( CommandBuilder::single_command("flyctl list orgs"), - fig_parse::lines, + output_parsers::pipe_table_name_col1_desc, ), ) } diff --git a/command-signatures/src/generators/fnm.rs b/command-signatures/src/generators/fnm.rs index 1ed3fbd1..261d8ad4 100644 --- a/command-signatures/src/generators/fnm.rs +++ b/command-signatures/src/generators/fnm.rs @@ -1,17 +1,20 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { CommandSignatureGenerators::new("fnm") .add_generator( "ls", - Generator::script(CommandBuilder::single_command("fnm ls"), fig_parse::lines), + Generator::script( + CommandBuilder::single_command("fnm ls"), + output_parsers::slice2_reversed, + ), ) .add_generator( "ls_remote", Generator::script( CommandBuilder::single_command("fnm ls-remote"), - fig_parse::lines, + output_parsers::second_whitespace_token, ), ) } diff --git a/command-signatures/src/generators/fvm.rs b/command-signatures/src/generators/fvm.rs index 4d00c0b9..f7d804b6 100644 --- a/command-signatures/src/generators/fvm.rs +++ b/command-signatures/src/generators/fvm.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "releases", Generator::script( CommandBuilder::single_command("fvm releases"), - fig_parse::lines, + output_parsers::unique_named_lines, ), ) } diff --git a/command-signatures/src/generators/gh.rs b/command-signatures/src/generators/gh.rs index 8a65602a..5aedc8bd 100644 --- a/command-signatures/src/generators/gh.rs +++ b/command-signatures/src/generators/gh.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::{fig_token, output_parsers}; use lazy_static::lazy_static; use regex::Regex; use warp_completion_metadata::{ @@ -50,16 +50,20 @@ pub fn generator() -> CommandSignatureGenerators { "api_graphql_string_viewer", Generator::script( CommandBuilder::single_command("gh api graphql --paginate -f query='query($endCursor: String) { viewer { repositories(first: 100, after: $endCursor) { nodes { isPrivate, nameWithOwner, description } pageInfo { hasNextPage endCursor }}}}' --jq '.data.viewer.repositories.nodes[]'"), - fig_parse::lines, + output_parsers::json_string_array, ), ) .add_generator( "git_branch", Generator::script( CommandBuilder::single_command("git --no-optional-locks branch -r --no-color --sort=-committerdate"), - fig_parse::lines, + crate::generators::git::post_process_branches, ), ) + .add_generator( + "repo_list_owner", + Generator::command_from_tokens(fig_token::gh_repo_list_for_owner, output_parsers::gh_repo_list_json), + ) } lazy_static! { diff --git a/command-signatures/src/generators/git.rs b/command-signatures/src/generators/git.rs index 3d1c69f2..c5af4931 100644 --- a/command-signatures/src/generators/git.rs +++ b/command-signatures/src/generators/git.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use itertools::Itertools; use warp_completion_metadata::{ Alias, CommandBuilder, CommandSignatureGenerators, Generator, GeneratorName, GeneratorResults, @@ -1028,40 +1028,67 @@ pub fn generator() -> CommandSignatureGenerators { }, ), ) +} + +fn git_generator_named(git: &CommandSignatureGenerators, name: &'static str) -> Generator { + git.generators() + .get(&GeneratorName::new(name)) + .cloned() + .unwrap_or_else(|| unreachable!("git registers {name}")) +} +/// `hub` is GitHub's git wrapper. Warp loads hub.json by filename (`hub`), not by +/// the spec's `name` field (`git`), so hub.json's generators must be keyed `hub`. +pub fn hub_generator() -> CommandSignatureGenerators { + let git = generator(); + CommandSignatureGenerators::new("hub") + .add_generator("aliases", git_generator_named(&git, "aliases")) + .add_generator("remotes", git_generator_named(&git, "remotes")) + .add_generator("revs", git_generator_named(&git, "revs")) + .add_generator( + "settings_generator", + git_generator_named(&git, "settings_generator"), + ) + .add_generator("stashes", git_generator_named(&git, "stashes")) + .add_generator("treeish", git_generator_named(&git, "treeish")) + .add_generator("tag", git_generator_named(&git, "tags")) .add_generator( "branches", Generator::script( - CommandBuilder::single_command("git --no-optional-locks branch --no-color --sort=-committerdate"), - fig_parse::lines, + CommandBuilder::single_command( + "git --no-optional-locks branch --no-color --sort=-committerdate", + ), + post_process_branches, ), ) .add_generator( "branches_no", Generator::script( - CommandBuilder::single_command("git --no-optional-locks branch -a --no-color --sort=-committerdate"), - fig_parse::lines, + CommandBuilder::single_command( + "git --no-optional-locks branch -a --no-color --sort=-committerdate", + ), + post_process_branches, ), ) .add_generator( "log", Generator::script( CommandBuilder::single_command("git --no-optional-locks log --oneline"), - fig_parse::lines, + output_parsers::git_oneline, ), ) .add_generator( "status", Generator::script( CommandBuilder::single_command("git --no-optional-locks status --short"), - fig_parse::lines, + output_parsers::git_status_short, ), ) .add_generator( - "tag", - Generator::script( - CommandBuilder::single_command("git --no-optional-locks tag --list --sort=-committerdate"), - fig_parse::lines, + "status_staged_or_unstaged", + Generator::command_from_tokens( + super::fig_token::git_status_staged_or_unstaged, + output_parsers::git_status_short, ), ) } diff --git a/command-signatures/src/generators/git_flow.rs b/command-signatures/src/generators/git_flow.rs new file mode 100644 index 00000000..45494775 --- /dev/null +++ b/command-signatures/src/generators/git_flow.rs @@ -0,0 +1,9 @@ +use super::{fig_token, output_parsers}; +use warp_completion_metadata::{CommandSignatureGenerators, Generator}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("git-flow").add_generator( + "type_branches", + Generator::command_from_tokens(fig_token::git_flow_type_branches, output_parsers::lines), + ) +} diff --git a/command-signatures/src/generators/gpg.rs b/command-signatures/src/generators/gpg.rs index ef977e50..6e97dbd5 100644 --- a/command-signatures/src/generators/gpg.rs +++ b/command-signatures/src/generators/gpg.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "completions", Generator::script( CommandBuilder::single_command("gpg --version"), - fig_parse::lines, + output_parsers::gpg_ciphers, ), ) } diff --git a/command-signatures/src/generators/hexo.rs b/command-signatures/src/generators/hexo.rs index 108c5fea..642dd624 100644 --- a/command-signatures/src/generators/hexo.rs +++ b/command-signatures/src/generators/hexo.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "list_post_draft", Generator::script( CommandBuilder::single_command("hexo list post | grep -E ^Draft"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/hugo.rs b/command-signatures/src/generators/hugo.rs index 0660addd..02a418fa 100644 --- a/command-signatures/src/generators/hugo.rs +++ b/command-signatures/src/generators/hugo.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "ls_archetypes", Generator::script( CommandBuilder::single_command("ls ./archetypes/"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/hyper.rs b/command-signatures/src/generators/hyper.rs index c97bf0d9..6b6613f9 100644 --- a/command-signatures/src/generators/hyper.rs +++ b/command-signatures/src/generators/hyper.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "list", Generator::script( CommandBuilder::single_command("hyper list"), - fig_parse::lines, + output_parsers::desc_plugin_name, ), ) } diff --git a/command-signatures/src/generators/id.rs b/command-signatures/src/generators/id.rs index 0c709170..b6a02bbb 100644 --- a/command-signatures/src/generators/id.rs +++ b/command-signatures/src/generators/id.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "dscl_users", Generator::script( CommandBuilder::single_command("dscl . -list /Users | grep -v '^_'"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/iex.rs b/command-signatures/src/generators/iex.rs new file mode 100644 index 00000000..b5f193d3 --- /dev/null +++ b/command-signatures/src/generators/iex.rs @@ -0,0 +1,6 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("iex").add_filter("filter-exs", template_filters::exs()) +} diff --git a/command-signatures/src/generators/ignite_cli.rs b/command-signatures/src/generators/ignite_cli.rs index 2137dcca..1cf8c7dd 100644 --- a/command-signatures/src/generators/ignite_cli.rs +++ b/command-signatures/src/generators/ignite_cli.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "ls_ignite_templates", Generator::script( CommandBuilder::single_command("ls ignite/templates"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/java.rs b/command-signatures/src/generators/java.rs new file mode 100644 index 00000000..0ec9b6dd --- /dev/null +++ b/command-signatures/src/generators/java.rs @@ -0,0 +1,8 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("java") + .add_filter("filter-java-class", template_filters::java_class()) + .add_filter("filter-jar", template_filters::jar()) +} diff --git a/command-signatures/src/generators/julia.rs b/command-signatures/src/generators/julia.rs new file mode 100644 index 00000000..734b83a4 --- /dev/null +++ b/command-signatures/src/generators/julia.rs @@ -0,0 +1,8 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("julia") + .add_filter("filter-jl", template_filters::jl()) + .add_filter("filter-dylib-so-dll", template_filters::dylib_so_dll()) +} diff --git a/command-signatures/src/generators/kool.rs b/command-signatures/src/generators/kool.rs index 764d4e7f..b1f57082 100644 --- a/command-signatures/src/generators/kool.rs +++ b/command-signatures/src/generators/kool.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "docker_compose_config", Generator::script( CommandBuilder::single_command("docker-compose config --services"), - fig_parse::lines, + output_parsers::lines, ), ) .add_generator( "run", Generator::script( CommandBuilder::single_command("kool run --help"), - fig_parse::lines, + output_parsers::desc_script, ), ) } diff --git a/command-signatures/src/generators/lerna.rs b/command-signatures/src/generators/lerna.rs index 67fed16d..aabaa295 100644 --- a/command-signatures/src/generators/lerna.rs +++ b/command-signatures/src/generators/lerna.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "git_branch", Generator::script( CommandBuilder::single_command("git branch --no-color"), - fig_parse::lines, + crate::generators::git::post_process_branches, ), ) .add_generator( "git_remote", Generator::script( CommandBuilder::single_command("git remote"), - fig_parse::lines, + output_parsers::desc_remote, ), ) .add_generator( @@ -23,11 +23,14 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( r"lerna list -p | while read p; do \cat $p/package.json && echo END done", ), - fig_parse::lines, + output_parsers::lerna_package_script_keys, ), ) .add_generator( "ls", - Generator::script(CommandBuilder::single_command("lerna ls"), fig_parse::lines), + Generator::script( + CommandBuilder::single_command("lerna ls"), + output_parsers::named_lines, + ), ) } diff --git a/command-signatures/src/generators/limactl.rs b/command-signatures/src/generators/limactl.rs index 248ce681..57af9434 100644 --- a/command-signatures/src/generators/limactl.rs +++ b/command-signatures/src/generators/limactl.rs @@ -1,12 +1,14 @@ -use super::fig_parse; +use super::{output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("limactl").add_generator( - "list", - Generator::script( - CommandBuilder::single_command("limactl list --quiet"), - fig_parse::lines, - ), - ) + CommandSignatureGenerators::new("limactl") + .add_generator( + "list", + Generator::script( + CommandBuilder::single_command("limactl list --quiet"), + output_parsers::desc_instance, + ), + ) + .add_filter("filter-yml-yaml", template_filters::yml_yaml()) } diff --git a/command-signatures/src/generators/mackup.rs b/command-signatures/src/generators/mackup.rs index 62c5bfed..dce798ad 100644 --- a/command-signatures/src/generators/mackup.rs +++ b/command-signatures/src/generators/mackup.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "list", Generator::script( CommandBuilder::single_command("mackup list"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/man.rs b/command-signatures/src/generators/man.rs index 00238984..420b15fa 100644 --- a/command-signatures/src/generators/man.rs +++ b/command-signatures/src/generators/man.rs @@ -3,46 +3,54 @@ use warp_completion_metadata::{ }; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("man").add_generator( - "list_man_pages", - Generator::command_from_tokens( - |tokens, _, _| { - let section_glob = match tokens.last() { - Some(maybe_section) - if maybe_section.len() == 1 - && *maybe_section >= "1" - && *maybe_section <= "8" => - { - maybe_section - } - // On a high-level, this code is try to get man completions for type 1 (general commands) and 8 (system admin and daemons) packages. - // man -w gives the all directories that contain man pages. These directories are further broken into sub-directories categorized by the type number. - // For example, a general command will live in man1 package and a system command will live in man8. - // What this command is doing is to chain all the different directories that have man pages and run ls to get all the page names. The [] operator in ls - // gives all possible values to match on. For example, ls man[18] will run ls man1 and ls man8 and chain together the output - _ => "[18]", - }; - CommandBuilder::pipe( - CommandBuilder::single_command(format!( - "ls -1 $(man -w | sed 's#:#/man{} #g')", - section_glob - )), + CommandSignatureGenerators::new("man") + .add_generator( + "sections_remaining", + Generator::command_from_tokens( + super::fig_token::man_sections_remaining, + super::output_parsers::lines, + ), + ) + .add_generator( + "list_man_pages", + Generator::command_from_tokens( + |tokens, _, _| { + let section_glob = match tokens.last() { + Some(maybe_section) + if maybe_section.len() == 1 + && *maybe_section >= "1" + && *maybe_section <= "8" => + { + maybe_section + } + // On a high-level, this code is try to get man completions for type 1 (general commands) and 8 (system admin and daemons) packages. + // man -w gives the all directories that contain man pages. These directories are further broken into sub-directories categorized by the type number. + // For example, a general command will live in man1 package and a system command will live in man8. + // What this command is doing is to chain all the different directories that have man pages and run ls to get all the page names. The [] operator in ls + // gives all possible values to match on. For example, ls man[18] will run ls man1 and ls man8 and chain together the output + _ => "[18]", + }; CommandBuilder::pipe( + CommandBuilder::single_command(format!( + "ls -1 $(man -w | sed 's#:#/man{} #g')", + section_glob + )), CommandBuilder::pipe( - CommandBuilder::single_command("cut -f 1 -d ."), - CommandBuilder::single_command("sort"), + CommandBuilder::pipe( + CommandBuilder::single_command("cut -f 1 -d ."), + CommandBuilder::single_command("sort"), + ), + CommandBuilder::single_command("uniq"), ), - CommandBuilder::single_command("uniq"), - ), - ) - }, - |output| { - output - .split('\n') - .filter(|&line| !line.is_empty() && !line.starts_with('/')) - .map(|line| Suggestion::with_description(line.trim(), "Man page")) - .collect_ordered_results() - }, - ), - ) + ) + }, + |output| { + output + .split('\n') + .filter(|&line| !line.is_empty() && !line.starts_with('/')) + .map(|line| Suggestion::with_description(line.trim(), "Man page")) + .collect_ordered_results() + }, + ), + ) } diff --git a/command-signatures/src/generators/mdfind.rs b/command-signatures/src/generators/mdfind.rs index 6244ea45..a8f2fd81 100644 --- a/command-signatures/src/generators/mdfind.rs +++ b/command-signatures/src/generators/mdfind.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "ls_library_saved_searches_savedsearch", Generator::script( CommandBuilder::single_command(r"ls -1A ~/Library/Saved\ Searches/*.savedSearch"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/meteor.rs b/command-signatures/src/generators/meteor.rs index 5368b124..abae0080 100644 --- a/command-signatures/src/generators/meteor.rs +++ b/command-signatures/src/generators/meteor.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::{output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,21 +7,22 @@ pub fn generator() -> CommandSignatureGenerators { "cat_meteor_packages", Generator::script( CommandBuilder::single_command("cat ./.meteor/packages"), - fig_parse::lines, + output_parsers::meteor_packages, ), ) .add_generator( "create", Generator::script( CommandBuilder::single_command("meteor create --list"), - fig_parse::lines, + output_parsers::meteor_examples, ), ) .add_generator( "list_platforms", Generator::script( CommandBuilder::single_command("meteor list-platforms"), - fig_parse::lines, + output_parsers::named_lines, ), ) + .add_filter("filter-json", template_filters::json()) } diff --git a/command-signatures/src/generators/mix.rs b/command-signatures/src/generators/mix.rs index 7f441cee..efc34375 100644 --- a/command-signatures/src/generators/mix.rs +++ b/command-signatures/src/generators/mix.rs @@ -1,9 +1,14 @@ -use super::fig_parse; +use super::{output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("mix").add_generator( - "help", - Generator::script(CommandBuilder::single_command("mix help"), fig_parse::lines), - ) + CommandSignatureGenerators::new("mix") + .add_generator( + "help", + Generator::script( + CommandBuilder::single_command("mix help"), + output_parsers::mix_help_tasks, + ), + ) + .add_filter("filter-exs", template_filters::exs()) } diff --git a/command-signatures/src/generators/mod.rs b/command-signatures/src/generators/mod.rs index d6a47cc3..791890b9 100644 --- a/command-signatures/src/generators/mod.rs +++ b/command-signatures/src/generators/mod.rs @@ -4,39 +4,52 @@ use warp_completion_metadata::DynamicCompletionData; mod amplify; mod ansible_doc; +mod ansible_playbook; mod assimp; mod autojump; mod bat; mod black; mod checkov; +mod chown; +mod cloudflared; mod cmd_n; mod common; mod copilot; mod cordova; +mod dd; +mod degit; mod deno; mod deployctl; mod deta; +mod direnv; mod dtm; mod eb; +mod elixir; mod elm; mod elm_review; +mod esbuild; mod eslint; mod expo; mod expo_cli; mod ffmpeg; -mod fig_parse; -mod fig_teams_latest; +mod fig_teams; +mod fig_token; +mod file; mod fisher; mod fly; mod flyctl; mod fnm; mod fvm; +mod git_flow; mod gpg; mod hexo; mod hugo; mod hyper; mod id; +mod iex; mod ignite_cli; +mod java; +mod julia; mod kool; mod lerna; mod limactl; @@ -46,21 +59,30 @@ mod meteor; mod mix; mod mosh; mod networkquality; +mod ni; mod npx; mod nr; mod ns; mod okteto; mod op; mod open; +mod osascript; +mod output_parsers; mod pandoc; +mod pdfunite; +mod pm2; +mod pod; mod pre_commit; mod projj; +mod python; mod quickmail; mod r; mod rancher; mod rclone; mod redwood; mod robot; +mod rollup; +mod rscript; mod rush; mod rushx; mod rustup; @@ -68,23 +90,32 @@ mod scc; mod sftp; mod shortcuts; mod softwareupdate; +mod sqlite3; +mod st2; mod stepzen; +mod subl; mod sysctl; mod tailscale; mod tccutil; +mod template_filters; mod terragrunt; mod tfenv; mod tfsec; mod tokei; mod trex; +mod trivy; +mod ts_node; +mod tsc; mod turbo; mod vite; mod vr; mod vsce; mod vultr_cli; +mod wasm_bindgen; mod watson; mod wd; mod wifi_password; +mod xcodeproj; mod yo; mod youtube_dl; @@ -190,6 +221,7 @@ pub fn dynamic_command_signature_data() -> HashMap HashMap HashMap HashMap HashMap HashMap HashMap HashMap HashMap CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "cat_ssh_config", Generator::script( CommandBuilder::single_command("cat ~/.ssh/config"), - fig_parse::lines, + output_parsers::ssh_hosts, ), ) .add_generator( "cat_ssh_known_hosts", - Generator::script( - CommandBuilder::single_command("cat ~/.ssh/known_hosts"), - fig_parse::lines, + Generator::command_from_tokens( + super::fig_token::known_hosts_file, + output_parsers::ssh_known_hosts, ), ) } diff --git a/command-signatures/src/generators/networkquality.rs b/command-signatures/src/generators/networkquality.rs index 52818c1e..fde1b43d 100644 --- a/command-signatures/src/generators/networkquality.rs +++ b/command-signatures/src/generators/networkquality.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "networksetup", Generator::script( CommandBuilder::single_command("networksetup -listallhardwareports"), - fig_parse::lines, + output_parsers::networksetup_ports, ), ) } diff --git a/command-signatures/src/generators/ni.rs b/command-signatures/src/generators/ni.rs new file mode 100644 index 00000000..03636858 --- /dev/null +++ b/command-signatures/src/generators/ni.rs @@ -0,0 +1,9 @@ +use super::{fig_token, output_parsers}; +use warp_completion_metadata::{CommandSignatureGenerators, Generator}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("ni").add_generator( + "npms_search", + Generator::command_from_tokens(fig_token::npms_search, output_parsers::npms_search_results), + ) +} diff --git a/command-signatures/src/generators/npm.rs b/command-signatures/src/generators/npm.rs index 36d70c88..a3468ce3 100644 --- a/command-signatures/src/generators/npm.rs +++ b/command-signatures/src/generators/npm.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{ Alias, CommandBuilder, CommandSignatureGenerators, Generator, GeneratorResults, GeneratorResultsCollector, Suggestion, @@ -269,6 +269,13 @@ pub fn npm_generators() -> CommandSignatureGenerators { .add_generator("workspace_generator", workspace_generator()) .add_generator("npm_registry_search", npm_registry_search_generator()) .add_alias("script_alias", script_alias_generator()) + .add_generator( + "npms_search", + Generator::command_from_tokens( + super::fig_token::npms_search, + output_parsers::npms_search_results, + ), + ) } fn workspace_packages_generator() -> Generator { @@ -327,7 +334,14 @@ pub fn pnpm_generators() -> CommandSignatureGenerators { "until_package_json_do_cd", Generator::script( CommandBuilder::single_command("until [[ -f package.json ]] || [[ $PWD = '/' ]]; do cd ..; done; cat package.json"), - fig_parse::lines, + output_parsers::json_script_keys, + ), + ) + .add_generator( + "npms_search", + Generator::command_from_tokens( + super::fig_token::npms_search, + output_parsers::npms_search_results, ), ) } @@ -382,6 +396,20 @@ pub fn yarn_generators() -> CommandSignatureGenerators { executables_within_node_modules(), ) .add_alias("script_alias", script_alias_generator()) + .add_generator( + "create_package_search", + Generator::command_from_tokens( + super::fig_token::npms_search_create_prefix, + super::output_parsers::npms_search_results, + ), + ) + .add_generator( + "npms_search", + Generator::command_from_tokens( + super::fig_token::npms_search, + super::output_parsers::npms_search_results, + ), + ) } #[cfg(test)] diff --git a/command-signatures/src/generators/npx.rs b/command-signatures/src/generators/npx.rs index ab1d6742..de88a644 100644 --- a/command-signatures/src/generators/npx.rs +++ b/command-signatures/src/generators/npx.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,7 +7,7 @@ pub fn generator() -> CommandSignatureGenerators { "until_node_modules_do_cd", Generator::script( CommandBuilder::single_command("until [[ -d node_modules/ ]] || [[ $PWD = '/' ]]; do cd ..; done; ls -1 node_modules/.bin/"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/nr.rs b/command-signatures/src/generators/nr.rs index 4a86e89d..86dcffda 100644 --- a/command-signatures/src/generators/nr.rs +++ b/command-signatures/src/generators/nr.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -8,7 +8,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "until [[ -f package.json ]] || [[ $PWD = '/' ]]; do cd ..; done; cat package.json", ), - fig_parse::lines, + output_parsers::json_script_keys, ), ) } diff --git a/command-signatures/src/generators/ns.rs b/command-signatures/src/generators/ns.rs index 3a5b79f5..2a203d24 100644 --- a/command-signatures/src/generators/ns.rs +++ b/command-signatures/src/generators/ns.rs @@ -1,13 +1,26 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; +fn nativescript_templates() -> Generator { + Generator::script( + CommandBuilder::single_command( + "curl -sfL -H 'User-Agent: warp-completions' -H 'Accept: application/vnd.github+json' https://api.github.com/repos/NativeScript/nativescript-app-templates/contents/packages", + ), + output_parsers::json_nativescript_templates, + ) +} + pub fn generator() -> CommandSignatureGenerators { CommandSignatureGenerators::new("ns") - .add_generator( - "curl_https_api_github_com_repos_nativescript_nativescript_app_templates_contents_packages", - Generator::script( - CommandBuilder::single_command("curl https://api.github.com/repos/NativeScript/nativescript-app-templates/contents/packages"), - fig_parse::lines, - ), - ) + .add_generator("nativescript_templates", nativescript_templates()) +} + +pub fn tns_generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("tns") + .add_generator("nativescript_templates", nativescript_templates()) +} + +pub fn nativescript_generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("nativescript") + .add_generator("nativescript_templates", nativescript_templates()) } diff --git a/command-signatures/src/generators/nx.rs b/command-signatures/src/generators/nx.rs index 22a976b1..c9d2b05a 100644 --- a/command-signatures/src/generators/nx.rs +++ b/command-signatures/src/generators/nx.rs @@ -151,6 +151,10 @@ pub fn generator() -> CommandSignatureGenerators { } }), ) + .add_generator( + "plugin_list", + Generator::command_from_tokens(super::fig_token::nx_list, super::output_parsers::named_lines), + ) } #[cfg(test)] diff --git a/command-signatures/src/generators/okteto.rs b/command-signatures/src/generators/okteto.rs index c6e26770..181e581c 100644 --- a/command-signatures/src/generators/okteto.rs +++ b/command-signatures/src/generators/okteto.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "context_list", Generator::script( CommandBuilder::single_command("okteto context list"), - fig_parse::lines, + output_parsers::okteto_contexts, ), ) .add_generator( "namespace_list", Generator::script( CommandBuilder::single_command("okteto namespace list"), - fig_parse::lines, + output_parsers::okteto_namespaces, ), ) } diff --git a/command-signatures/src/generators/op.rs b/command-signatures/src/generators/op.rs index c13c57bf..874e01e7 100644 --- a/command-signatures/src/generators/op.rs +++ b/command-signatures/src/generators/op.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "account_list_json", Generator::script( CommandBuilder::single_command("op account list --format json"), - fig_parse::lines, + output_parsers::op_accounts, ), ) } diff --git a/command-signatures/src/generators/open.rs b/command-signatures/src/generators/open.rs index 14c2bd46..774717db 100644 --- a/command-signatures/src/generators/open.rs +++ b/command-signatures/src/generators/open.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "mdfind", Generator::script( CommandBuilder::single_command("mdfind kMDItemContentTypeTree=com.apple.application-bundle -onlyin /"), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( "mdfind_while_read_line", Generator::script( CommandBuilder::single_command(r#"mdfind kMDItemContentTypeTree=com.apple.application-bundle -onlyin / | while read line; do echo $(mdls -name kMDItemCFBundleIdentifier -r "$line") $line; done"#), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/osascript.rs b/command-signatures/src/generators/osascript.rs new file mode 100644 index 00000000..4e79235b --- /dev/null +++ b/command-signatures/src/generators/osascript.rs @@ -0,0 +1,6 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("osascript").add_filter("filter-scpt", template_filters::scpt()) +} diff --git a/command-signatures/src/generators/output_parsers.rs b/command-signatures/src/generators/output_parsers.rs new file mode 100644 index 00000000..f0ef15e9 --- /dev/null +++ b/command-signatures/src/generators/output_parsers.rs @@ -0,0 +1,1101 @@ +use serde_json::Value; +use warp_completion_metadata::{GeneratorResults, GeneratorResultsCollector, Suggestion}; + +/// One suggestion per non-empty trimmed line. +pub fn lines(output: &str) -> GeneratorResults { + nonempty_lines(output) + .map(Suggestion::new) + .collect_unordered_results() +} + +pub fn named_lines(output: &str) -> GeneratorResults { + lines(output) +} + +pub fn unique_named_lines(output: &str) -> GeneratorResults { + let mut seen = std::collections::HashSet::new(); + nonempty_lines(output) + .filter(|&line| seen.insert(line.to_string())) + .map(Suggestion::new) + .collect_unordered_results() +} + +pub fn desc_plugin(output: &str) -> GeneratorResults { + lines_with_desc(output, "Plugin") +} + +pub fn desc_plugin_name(output: &str) -> GeneratorResults { + lines_with_desc(output, "Plugin name") +} + +pub fn desc_remote(output: &str) -> GeneratorResults { + lines_with_desc(output, "Remote") +} + +pub fn desc_script(output: &str) -> GeneratorResults { + lines_with_desc(output, "Script") +} + +pub fn desc_version(output: &str) -> GeneratorResults { + lines_with_desc(output, "Version") +} + +pub fn desc_variable(output: &str) -> GeneratorResults { + lines_with_desc(output, "Variable name") +} + +pub fn desc_workspace(output: &str) -> GeneratorResults { + nonempty_lines(output) + .map(|line| Suggestion::with_description(line.replace('*', "").trim(), "Workspace")) + .collect_unordered_results() +} + +pub fn desc_terraform_workspace(output: &str) -> GeneratorResults { + nonempty_lines(output) + .map(|line| { + Suggestion::with_description(line.replace('*', "").trim(), "Terraform workspaces") + }) + .collect_unordered_results() +} + +pub fn desc_address(output: &str) -> GeneratorResults { + if output.contains("No state file") || output.contains("Error") { + return empty(); + } + nonempty_lines(output) + .map(|line| Suggestion::with_description(line.replace('*', "").trim(), "Address")) + .collect_unordered_results() +} + +pub fn git_status_short(output: &str) -> GeneratorResults { + if output.trim_start().starts_with("fatal:") { + return empty(); + } + output + .lines() + .filter(|line| !line.is_empty()) + .filter_map(|line| { + let path = line.get(3..)?.trim(); + (!path.is_empty()).then(|| Suggestion::with_description(path, line)) + }) + .collect_unordered_results() +} + +pub fn pre_commit_hook_ids(output: &str) -> GeneratorResults { + yaml_pre_commit_hook_ids(output) + .into_iter() + .map(Suggestion::new) + .collect_unordered_results() +} + +pub fn ssh_known_hosts(output: &str) -> GeneratorResults { + let mut prefix = String::new(); + let mut seen = std::collections::HashSet::new(); + let mut hosts = Vec::new(); + for line in nonempty_lines(output) { + if let Some(rest) = line.strip_prefix("WARP_SSH_USER_PREFIX=") { + prefix = rest.to_string(); + continue; + } + for host in known_host_names(line) { + if seen.insert(host.clone()) { + hosts.push(host); + } + } + } + hosts + .into_iter() + .map(|host| Suggestion::with_description(format!("{prefix}{host}"), "SSH host")) + .collect_unordered_results() +} + +pub fn deno_binaries(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter(|line| !line.ends_with("/deno")) + .map(|line| { + let name = line.rsplit('/').next().unwrap_or(line); + Suggestion::with_description(name, line) + }) + .collect_unordered_results() +} + +pub fn eslint_plugin_names(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter(|line| line.starts_with("eslint-plugin")) + .map(|line| { + let name = line.split_whitespace().next().unwrap_or(line); + Suggestion::new(name.get(14..).unwrap_or(name)) + }) + .collect_unordered_results() +} + +pub fn mix_help_tasks(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter_map(|line| { + let (name, description) = match line.split_once('#') { + Some((name, description)) => (name.trim(), description.trim()), + None => (line.trim(), ""), + }; + let name = name.strip_prefix("mix ").unwrap_or(name); + (!["mix", "help", "new", "run", "iex -S mix"].contains(&name)) + .then(|| Suggestion::with_description(name, description)) + }) + .collect_unordered_results() +} + +pub fn meteor_packages(output: &str) -> GeneratorResults { + if output.contains("No such file or directory") { + return empty(); + } + nonempty_lines(output) + .filter_map(|line| { + let name = line.split('#').next().unwrap_or(line).trim(); + let name = name.split('@').next().unwrap_or(name).trim(); + (!name.is_empty()).then(|| Suggestion::new(name)) + }) + .collect_unordered_results() +} + +pub fn meteor_examples(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter(|line| line.contains("github.com")) + .map(|line| Suggestion::new(line.split(':').next().unwrap_or(line).trim())) + .collect_unordered_results() +} + +pub fn softwareupdate_labels(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter_map(|line| { + line.strip_prefix("* Label: ").map(|name| { + Suggestion::with_description(format!("\"{name}\""), "Available update") + .with_display_name(Some(name.to_string())) + }) + }) + .collect_unordered_results() +} + +pub fn networksetup_ports(output: &str) -> GeneratorResults { + let re = regex::Regex::new(r"(?s)Hardware Port: (.*?)\n.*?Device: (.*?)(?:\n|$)").ok(); + let Some(re) = re else { + return empty(); + }; + re.captures_iter(output) + .filter_map(|caps| { + Some(Suggestion::with_description( + caps.get(2)?.as_str(), + caps.get(1)?.as_str(), + )) + }) + .collect_unordered_results() +} + +fn skip_star_first_token(output: &str, description: &'static str) -> GeneratorResults { + nonempty_lines(output) + .skip(1) + .filter_map(|line| { + let token = line.split_whitespace().next()?.replace('*', ""); + let name = token.trim(); + (!name.is_empty()).then(|| Suggestion::with_description(name, description)) + }) + .collect_unordered_results() +} + +pub fn okteto_contexts(output: &str) -> GeneratorResults { + skip_star_first_token(output, "Context") +} + +pub fn okteto_namespaces(output: &str) -> GeneratorResults { + skip_star_first_token(output, "Namespace") +} + +pub fn redwood_scripts(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter(|line| line.ends_with(".js") || line.ends_with(".ts")) + .map(|line| { + let name = line.trim(); + let name = name.rsplit_once('.').map(|(stem, _)| stem).unwrap_or(name); + Suggestion::with_description(name, "Script") + }) + .collect_unordered_results() +} + +pub fn wifi_networks(output: &str) -> GeneratorResults { + nonempty_lines(output) + .skip(1) + .map(|line| Suggestion::new(line.trim())) + .collect_unordered_results() +} + +pub fn gpg_ciphers(output: &str) -> GeneratorResults { + let Some(start) = output.find("Cypher: ").or_else(|| output.find("Cipher: ")) else { + return empty(); + }; + let rest = &output[start + 8..]; + let end = rest.find("Hash: ").unwrap_or(rest.len()); + let list = rest[..end].split_whitespace().collect::(); + list.split(',') + .filter(|part| !part.is_empty()) + .map(Suggestion::new) + .collect_unordered_results() +} + +pub fn desc_extension(output: &str) -> GeneratorResults { + split_on(output, ';', "Extension") +} + +pub fn desc_runtime(output: &str) -> GeneratorResults { + split_on(output, ',', "Runtime") +} + +pub fn desc_instance(output: &str) -> GeneratorResults { + lines_with_desc(output, "Instance name") +} + +pub fn desc_warp_point(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter_map(|line| line.split_whitespace().next()) + .map(|name| Suggestion::with_description(name, "Warp point")) + .collect_unordered_results() +} + +pub fn json_envs(output: &str) -> GeneratorResults { + match json(output).and_then(|v| v.get("envs").cloned()) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + value + .as_str() + .map(|name| Suggestion::with_description(name, "Environment")) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn json_name_summary(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + let name = value.get("name")?.as_str()?; + let description = value.get("summary").and_then(Value::as_str).unwrap_or(""); + Some(Suggestion::with_description(name, description)) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn json_deno_doc_nodes(output: &str) -> GeneratorResults { + let Some(value) = json(output) else { + return empty(); + }; + let Some(nodes) = value.get("nodes").and_then(Value::as_array) else { + return empty(); + }; + nodes + .iter() + .filter_map(|node| { + let name = node.get("name")?.as_str()?; + (!name.is_empty()).then(|| { + let description = node + .get("jsDoc") + .and_then(|js_doc| js_doc.get("doc")) + .and_then(Value::as_str) + .unwrap_or(""); + Suggestion::with_description(name, description) + }) + }) + .collect_unordered_results() +} + +pub fn json_string_array(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| value.as_str().map(Suggestion::new)) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn json_object_key_descriptions(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Object(map)) => map + .into_iter() + .map(|(name, value)| { + let description = match value { + Value::String(s) => s, + other => other.as_str().map(str::to_owned).unwrap_or_default(), + }; + Suggestion::with_description(name, description) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn tailscale_peers(output: &str) -> GeneratorResults { + tailscale_peers_with_suffix(output, "") +} + +pub fn tailscale_peers_colon(output: &str) -> GeneratorResults { + tailscale_peers_with_suffix(output, ":") +} + +pub fn op_accounts(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + let email = value.get("email")?.as_str()?; + let url = value.get("url").and_then(Value::as_str).unwrap_or(""); + let uuid = value.get("account_uuid")?.as_str()?; + Some( + Suggestion::with_description(uuid, url) + .with_display_name(Some(email.to_string())), + ) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn projj_cache_repos(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Object(map)) => map + .into_iter() + .map(|(key, value)| { + let name = key.rsplit('/').next().unwrap_or(&key); + let description = value.get("repo").and_then(Value::as_str).unwrap_or(""); + Suggestion::with_description(name, description) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn projj_hooks(output: &str) -> GeneratorResults { + match json(output).and_then(|v| v.get("hooks").cloned()) { + Some(Value::Object(map)) => map + .into_iter() + .map(|(name, value)| { + let description = match value { + Value::String(s) => s, + other => other.to_string(), + }; + Suggestion::with_description(name, description) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn trex_imports(output: &str) -> GeneratorResults { + if output.trim().is_empty() { + return empty(); + } + match json(output).and_then(|v| v.get("imports").cloned()) { + Some(Value::Object(map)) => map + .into_iter() + .map(|(name, value)| { + let description = value.as_str().unwrap_or(""); + Suggestion::with_description(name, description) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn trex_scripts(output: &str) -> GeneratorResults { + if output.trim().is_empty() { + return empty(); + } + match json(output).and_then(|v| v.get("scripts").cloned()) { + Some(Value::Object(map)) => map + .into_iter() + .map(|(name, _)| Suggestion::with_description(name, "trex script")) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn turbo_pipeline(output: &str) -> GeneratorResults { + match json(output).and_then(|v| v.get("pipeline").cloned()) { + Some(Value::Object(map)) => map + .into_iter() + .map(|(name, value)| { + let mut parts = Vec::new(); + if let Some(Value::Array(depends)) = value.get("dependsOn") { + let items: Vec<_> = depends + .iter() + .filter_map(Value::as_str) + .map(|item| format!("'{item}'")) + .collect(); + if !items.is_empty() { + parts.push(format!("depends on {}", items.join(", "))); + } + } + if let Some(Value::Array(outputs)) = value.get("outputs") { + let items: Vec<_> = outputs + .iter() + .filter_map(Value::as_str) + .map(|item| format!("'{item}'")) + .collect(); + if !items.is_empty() { + parts.push(format!("outputs {}", items.join(", "))); + } + } + let description = if parts.is_empty() { + "Task".to_string() + } else { + format!("Task: {}", parts.join(", ")) + }; + Suggestion::with_description(name, description) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn cargo_read_manifest_bins(output: &str) -> GeneratorResults { + match json(output).and_then(|v| v.get("targets").cloned()) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|target| { + let is_bin = target + .get("kind") + .and_then(Value::as_array) + .is_some_and(|kind| kind.iter().any(|item| item.as_str() == Some("bin"))); + is_bin + .then(|| { + target + .get("name") + .and_then(Value::as_str) + .map(Suggestion::new) + }) + .flatten() + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn json_cordova_platforms(output: &str) -> GeneratorResults { + match json(output) + .and_then(|v| v.get("cordova").cloned()) + .and_then(|cordova| cordova.get("platforms").cloned()) + { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + value + .as_str() + .map(|name| Suggestion::with_description(name, "Platform")) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn json_rush_projects(output: &str) -> GeneratorResults { + if output.trim().is_empty() { + return empty(); + } + match json(output).and_then(|v| v.get("projects").cloned()) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + value + .get("packageName") + .and_then(Value::as_str) + .map(|name| Suggestion::with_description(name, "Projects")) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn json_deno_codes(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + let name = value.get("code")?.as_str()?; + let docs = value.get("docs").and_then(Value::as_str).unwrap_or(""); + let description = docs.split("\n\n").next().unwrap_or(docs); + Some(Suggestion::with_description(name, description)) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn json_nativescript_templates(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + let name = value.get("name")?.as_str()?; + Some(Suggestion::with_description( + format!("@nativescript/{name}"), + format!("Template {name}"), + )) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn pipe_table_name_col1_desc(output: &str) -> GeneratorResults { + pipe_table(output, 2, 0, Some(1)) +} + +pub fn git_oneline(output: &str) -> GeneratorResults { + let output = output.trim_start(); + if output.starts_with("fatal:") { + return empty(); + } + nonempty_lines(output) + .map(|line| { + let (hash, rest) = line.split_at(line.len().min(7)); + Suggestion::with_description(hash, rest) + }) + .collect_unordered_results() +} + +pub fn apt_package_before_slash(output: &str) -> GeneratorResults { + nonempty_lines(output) + .map(|line| { + let name = line.split_once('/').map(|(name, _)| name).unwrap_or(line); + Suggestion::with_description(name, "Package") + }) + .collect_unordered_results() +} + +pub fn strip_star_prefix(output: &str) -> GeneratorResults { + nonempty_lines(output) + .map(|line| { + let name = line + .strip_prefix('*') + .map(str::trim) + .unwrap_or_else(|| line.trim()); + Suggestion::new(name) + }) + .collect_unordered_results() +} + +pub fn second_whitespace_token(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter_map(|line| { + line.split_whitespace() + .nth(1) + .filter(|token| *token != "=") + .map(Suggestion::new) + }) + .collect_unordered_results() +} + +pub fn slice2_reversed(output: &str) -> GeneratorResults { + let names: Vec<_> = nonempty_lines(output) + .filter_map(|line| line.get(2..)) + .map(|name| Suggestion::with_description(name, format!("Node.js {name}"))) + .collect(); + GeneratorResults { + suggestions: names.into_iter().rev().collect(), + is_ordered: true, + } +} + +pub fn yaml_application(output: &str) -> GeneratorResults { + if output.trim().is_empty() { + return empty(); + } + for line in output.lines() { + let line = line.trim(); + if let Some(value) = line.strip_prefix("application:") { + let name = value.trim().trim_matches('"').trim_matches('\''); + if !name.is_empty() { + return std::iter::once(Suggestion::new(name)).collect_unordered_results(); + } + } + } + empty() +} + +pub fn descending_count(output: &str) -> GeneratorResults { + let Ok(count) = output.trim().parse::() else { + return empty(); + }; + (1..=count) + .rev() + .map(|n| Suggestion::new(n.to_string())) + .collect_ordered_results() +} + +pub fn json_script_keys(output: &str) -> GeneratorResults { + if output.trim().is_empty() { + return empty(); + } + match json(output).and_then(|v| v.get("scripts").cloned()) { + Some(Value::Object(map)) => map + .into_iter() + .map(|(name, value)| { + let description = value.as_str().unwrap_or("Script"); + Suggestion::with_description(name, description) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn npms_search_results(output: &str) -> GeneratorResults { + match json(output).and_then(|v| v.get("results").cloned()) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + let package = value.get("package")?; + let name = package.get("name")?.as_str()?; + let description = package + .get("description") + .and_then(Value::as_str) + .unwrap_or(""); + Some(Suggestion::with_description(name, description)) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn json_crates(output: &str) -> GeneratorResults { + match json(output).and_then(|v| v.get("crates").cloned()) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + let name = value.get("name")?.as_str()?; + let description = value + .get("description") + .and_then(Value::as_str) + .map(str::to_owned) + .or_else(|| { + value + .get("newest_version") + .and_then(Value::as_str) + .map(|version| format!("v{version}")) + }) + .unwrap_or_default(); + Some(Suggestion::with_description(name, description)) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn gh_repo_list_json(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + let name = value.get("nameWithOwner")?.as_str()?; + let description = value + .get("description") + .and_then(Value::as_str) + .unwrap_or(""); + Some(Suggestion::with_description(name, description)) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn github_repos_json(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + let name = value.get("full_name")?.as_str()?; + let description = value + .get("description") + .and_then(Value::as_str) + .unwrap_or("Repository"); + Some(Suggestion::with_description(name, description)) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn robot_variables(output: &str) -> GeneratorResults { + let mut seen = std::collections::HashSet::new(); + nonempty_lines(output) + .filter_map(|line| { + let start = line.find("${")?; + let rest = &line[start + 2..]; + let end = rest.find('}')?; + let name = rest[..end].trim(); + (!name.is_empty() && seen.insert(name.to_string())) + .then(|| Suggestion::with_description(name, "Variable")) + }) + .collect_unordered_results() +} + +pub fn robot_test_cases(output: &str) -> GeneratorResults { + let mut seen = std::collections::HashSet::new(); + let mut in_tests = false; + output + .lines() + .filter_map(|line| { + let trimmed = line.trim(); + if trimmed.eq_ignore_ascii_case("*** Test Cases ***") + || trimmed.eq_ignore_ascii_case("***Test Cases***") + { + in_tests = true; + return None; + } + if in_tests && trimmed.starts_with("***") { + in_tests = false; + return None; + } + if !in_tests || line.starts_with(' ') || line.starts_with('\t') || trimmed.is_empty() { + return None; + } + let name = trimmed.split('#').next().unwrap_or(trimmed).trim(); + if name.is_empty() || name.contains(" ") { + return None; + } + seen.insert(name.to_string()) + .then(|| Suggestion::with_description(name, "Test case")) + }) + .collect_unordered_results() +} + +pub fn robot_tags(output: &str) -> GeneratorResults { + let mut seen = std::collections::HashSet::new(); + nonempty_lines(output) + .filter_map(|line| { + let trimmed = line.trim_start(); + trimmed.strip_prefix("[Tags]") + }) + .flat_map(|rest| { + rest.split(" ") + .map(str::trim) + .filter(|tag| !tag.is_empty() && !tag.starts_with('#')) + .map(str::to_string) + .collect::>() + }) + .filter_map(|tag| { + seen.insert(tag.clone()) + .then(|| Suggestion::with_description(tag, "Tag")) + }) + .collect_unordered_results() +} + +pub fn scc_languages(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter_map(|line| { + let (name, _) = line.rsplit_once(" (")?; + Some(Suggestion::new(name.trim())) + }) + .collect_unordered_results() +} + +pub fn docker_search_names(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter_map(|line| { + json(line)? + .get("Name") + .and_then(Value::as_str) + .map(Suggestion::new) + }) + .collect_unordered_results() +} + +pub fn stepzen_schema_names(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + value + .as_str() + .map(|name| Suggestion::with_description(name, "StepZen endpoint")) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn stepzen_github_dirs(output: &str) -> GeneratorResults { + match json(output) { + Some(Value::Array(arr)) => arr + .into_iter() + .filter_map(|value| { + let kind = value.get("type")?.as_str()?; + let name = value.get("name")?.as_str()?; + (kind == "dir" && !name.starts_with('.')) + .then(|| Suggestion::with_description(name, "Stepzen schema")) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn youtube_dl_flat_playlist(output: &str) -> GeneratorResults { + match json(output).and_then(|v| v.get("entries").cloned()) { + Some(Value::Array(arr)) => arr + .into_iter() + .enumerate() + .map(|(index, entry)| { + let title = entry.get("title").and_then(Value::as_str).unwrap_or(""); + let uploader = entry.get("uploader").and_then(Value::as_str).unwrap_or(""); + let n = index + 1; + Suggestion::with_description(n.to_string(), uploader) + .with_display_name(Some(format!("{n} - {title}"))) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +pub fn youtube_clipboard_url(output: &str) -> GeneratorResults { + let value = output.trim(); + let is_youtube = value.contains("youtube.com") || value.contains("youtu.be"); + if is_youtube { + std::iter::once(Suggestion::with_description(value, "Clipboard")) + .collect_unordered_results() + } else { + empty() + } +} + +pub fn lerna_package_script_keys(output: &str) -> GeneratorResults { + let mut names = std::collections::BTreeSet::new(); + for chunk in output.split("END") { + let chunk = chunk.trim(); + if chunk.is_empty() { + continue; + } + let Some(Value::Object(map)) = json(chunk) else { + continue; + }; + let Some(Value::Object(scripts)) = map.get("scripts") else { + continue; + }; + names.extend(scripts.keys().cloned()); + } + names + .into_iter() + .map(Suggestion::new) + .collect_unordered_results() +} + +pub fn docker_from_as_names(output: &str) -> GeneratorResults { + let re = regex::Regex::new(r"(?i)(?:as)\s+([\w:.-]+)").ok(); + nonempty_lines(output) + .filter_map(|line| { + re.as_ref() + .and_then(|re| re.captures(line)) + .and_then(|c| c.get(1)) + .map(|m| Suggestion::new(m.as_str())) + }) + .collect_unordered_results() +} + +pub fn ssh_hosts(output: &str) -> GeneratorResults { + nonempty_lines(output) + .filter(|line| line.trim().starts_with("Host ") && !line.contains('*')) + .filter_map(|line| line.split_whitespace().nth(1)) + .map(|name| Suggestion::with_description(name, "SSH host")) + .collect_unordered_results() +} + +fn known_host_names(line: &str) -> Vec { + let line = line.trim(); + if line.is_empty() || line.starts_with('#') { + return Vec::new(); + } + let mut fields = line.split_whitespace(); + let mut first = fields.next().unwrap_or(""); + if first.starts_with('@') { + first = fields.next().unwrap_or(""); + } + if first.is_empty() || first.starts_with("|1|") { + return Vec::new(); + } + first + .split(',') + .filter_map(|host| { + let host = host.trim(); + let host = host + .strip_prefix('[') + .and_then(|h| h.split(']').next()) + .unwrap_or(host); + if host.is_empty() || host.contains('*') { + None + } else { + Some(host.to_string()) + } + }) + .collect() +} + +fn yaml_pre_commit_hook_ids(output: &str) -> Vec { + let mut ids = Vec::new(); + let mut in_repos = false; + let mut in_hooks = false; + let mut repos_indent = usize::MAX; + let mut hooks_indent = usize::MAX; + for raw in output.lines() { + let indent = raw.chars().take_while(|c| *c == ' ' || *c == '\t').count(); + let trimmed = raw.trim(); + if trimmed.is_empty() || trimmed.starts_with('#') { + continue; + } + if in_repos + && indent <= repos_indent + && !is_sequence_item(trimmed) + && key_name(trimmed) != "repos" + { + in_repos = false; + in_hooks = false; + } + if in_hooks + && indent <= hooks_indent + && !is_sequence_item(trimmed) + && key_name(trimmed) != "hooks" + { + in_hooks = false; + } + match key_name(trimmed) { + "repos" => { + in_repos = true; + repos_indent = indent; + in_hooks = false; + continue; + } + "hooks" if in_repos => { + in_hooks = true; + hooks_indent = indent; + continue; + } + "id" if in_hooks => { + if let Some(id) = yaml_scalar_value(trimmed) { + ids.push(id); + } + } + _ => {} + } + } + ids +} + +fn is_sequence_item(trimmed: &str) -> bool { + trimmed == "-" || trimmed.starts_with("- ") +} + +fn key_name(trimmed: &str) -> &str { + let line = trimmed.strip_prefix("- ").unwrap_or(trimmed); + line.split(':').next().unwrap_or("").trim() +} + +fn yaml_scalar_value(trimmed: &str) -> Option { + let line = trimmed.strip_prefix("- ").unwrap_or(trimmed); + let (_, value) = line.split_once(':')?; + let value = value.trim(); + if value.is_empty() || value == "|" || value == ">" || value == "{" || value == "[" { + return None; + } + let quote = match value.as_bytes().first() { + Some(b) if *b == b'"' || *b == b'\'' => Some(*b as char), + _ => None, + }; + if let Some(quote) = quote { + let rest = &value[1..]; + let end = rest.find(quote)?; + let inner = &rest[..end]; + return (!inner.is_empty()).then(|| inner.to_string()); + } + let unquoted = value + .split_once('#') + .map(|(code, _)| code.trim()) + .unwrap_or(value); + (!unquoted.is_empty()).then(|| unquoted.to_string()) +} + +fn nonempty_lines(output: &str) -> impl Iterator { + output + .lines() + .map(str::trim) + .filter(|line| !line.is_empty()) +} + +fn lines_with_desc(output: &str, description: &'static str) -> GeneratorResults { + nonempty_lines(output) + .map(|line| Suggestion::with_description(line, description)) + .collect_unordered_results() +} + +fn split_on(output: &str, sep: char, description: &'static str) -> GeneratorResults { + output + .split(sep) + .map(str::trim) + .filter(|part| !part.is_empty()) + .map(|part| Suggestion::with_description(part, description)) + .collect_unordered_results() +} + +fn pipe_table( + output: &str, + skip: usize, + name_col: usize, + desc_col: Option, +) -> GeneratorResults { + nonempty_lines(output) + .skip(skip) + .filter_map(|line| { + let cols: Vec<_> = line.split('|').map(str::trim).collect(); + let name = cols.get(name_col).copied().filter(|s| !s.is_empty())?; + match desc_col.and_then(|i| cols.get(i).copied()) { + Some(description) if !description.is_empty() => { + Some(Suggestion::with_description(name, description)) + } + _ => Some(Suggestion::new(name)), + } + }) + .collect_unordered_results() +} + +fn tailscale_peers_with_suffix(output: &str, suffix: &str) -> GeneratorResults { + match json(output).and_then(|v| v.get("Peer").cloned()) { + Some(Value::Object(map)) => map + .into_values() + .filter_map(|peer| { + let dns = peer.get("DNSName")?.as_str()?; + let short = dns.split('.').next().unwrap_or(dns); + let host = peer.get("HostName").and_then(Value::as_str).unwrap_or(""); + let os = peer.get("OS").and_then(Value::as_str).unwrap_or(""); + let description = match (host.is_empty(), os.is_empty()) { + (true, true) => String::new(), + (false, true) => host.to_string(), + (true, false) => os.to_string(), + (false, false) => format!("{host} ({os})"), + }; + Some(Suggestion::with_description( + format!("{short}{suffix}"), + description, + )) + }) + .collect_unordered_results(), + _ => empty(), + } +} + +fn json(output: &str) -> Option { + serde_json::from_str(output.trim()).ok() +} + +fn empty() -> GeneratorResults { + GeneratorResults { + suggestions: vec![], + is_ordered: false, + } +} diff --git a/command-signatures/src/generators/pandoc.rs b/command-signatures/src/generators/pandoc.rs index 22f0d094..dcd06989 100644 --- a/command-signatures/src/generators/pandoc.rs +++ b/command-signatures/src/generators/pandoc.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::{output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "completions", Generator::script( CommandBuilder::single_command("pandoc --list-output-formats"), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( "completions_list", Generator::script( CommandBuilder::single_command("pandoc --list-input-formats"), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( @@ -23,7 +23,9 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "pandoc --list-input-formats && pandoc --list-output-formats", ), - fig_parse::lines, + output_parsers::unique_named_lines, ), ) + .add_filter("filter-yaml", template_filters::yaml()) + .add_filter("filter-yaml-json", template_filters::yaml_json()) } diff --git a/command-signatures/src/generators/pdfunite.rs b/command-signatures/src/generators/pdfunite.rs new file mode 100644 index 00000000..6b09aba2 --- /dev/null +++ b/command-signatures/src/generators/pdfunite.rs @@ -0,0 +1,6 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("pdfunite").add_filter("filter-pdf", template_filters::pdf()) +} diff --git a/command-signatures/src/generators/phpunit_watcher.rs b/command-signatures/src/generators/phpunit_watcher.rs index 6cc20cfe..8cb6ec08 100644 --- a/command-signatures/src/generators/phpunit_watcher.rs +++ b/command-signatures/src/generators/phpunit_watcher.rs @@ -4,7 +4,7 @@ use warp_completion_metadata::{ }; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("phpunit").add_generator( + CommandSignatureGenerators::new("phpunit-watcher").add_generator( "tests", Generator::script( CommandBuilder::single_command("phpunit --list-tests"), diff --git a/command-signatures/src/generators/pm2.rs b/command-signatures/src/generators/pm2.rs new file mode 100644 index 00000000..8abe748a --- /dev/null +++ b/command-signatures/src/generators/pm2.rs @@ -0,0 +1,6 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("pm2").add_filter("filter-json", template_filters::json()) +} diff --git a/command-signatures/src/generators/pod.rs b/command-signatures/src/generators/pod.rs new file mode 100644 index 00000000..290f93ef --- /dev/null +++ b/command-signatures/src/generators/pod.rs @@ -0,0 +1,6 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("pod").add_filter("filter-podspec", template_filters::podspec()) +} diff --git a/command-signatures/src/generators/pre_commit.rs b/command-signatures/src/generators/pre_commit.rs index 4cfc2b78..d8a374b3 100644 --- a/command-signatures/src/generators/pre_commit.rs +++ b/command-signatures/src/generators/pre_commit.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,7 +7,7 @@ pub fn generator() -> CommandSignatureGenerators { "cat_pre_commit_config_yaml", Generator::script( CommandBuilder::single_command("cat .pre-commit-config.yaml"), - fig_parse::lines, + output_parsers::pre_commit_hook_ids, ), ) .add_generator( @@ -16,7 +16,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "git --no-optional-locks branch --no-color --sort=-committerdate", ), - fig_parse::lines, + crate::generators::git::post_process_branches, ), ) .add_generator( @@ -25,21 +25,21 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "git --no-optional-locks branch -a --no-color --sort=-committerdate", ), - fig_parse::lines, + crate::generators::git::post_process_branches, ), ) .add_generator( "git_remote", Generator::script( CommandBuilder::single_command("git --no-optional-locks remote -v"), - fig_parse::lines, + output_parsers::desc_remote, ), ) .add_generator( "git_rev_list", Generator::script( CommandBuilder::single_command("git rev-list --all --oneline"), - fig_parse::lines, + output_parsers::git_oneline, ), ) } diff --git a/command-signatures/src/generators/projj.rs b/command-signatures/src/generators/projj.rs index 1bba51fc..fcaa35ed 100644 --- a/command-signatures/src/generators/projj.rs +++ b/command-signatures/src/generators/projj.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "cat_projj_cache_json", Generator::script( CommandBuilder::single_command("cat ~/.projj/cache.json"), - fig_parse::lines, + output_parsers::projj_cache_repos, ), ) .add_generator( "cat_projj_config_json", Generator::script( CommandBuilder::single_command("cat ~/.projj/config.json"), - fig_parse::lines, + output_parsers::projj_hooks, ), ) } diff --git a/command-signatures/src/generators/python.rs b/command-signatures/src/generators/python.rs new file mode 100644 index 00000000..0b3c59ec --- /dev/null +++ b/command-signatures/src/generators/python.rs @@ -0,0 +1,10 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("python").add_filter("filter-py", template_filters::py()) +} + +pub fn python3_generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("python3").add_filter("filter-py", template_filters::py()) +} diff --git a/command-signatures/src/generators/quickmail.rs b/command-signatures/src/generators/quickmail.rs index ce226499..e8b628fa 100644 --- a/command-signatures/src/generators/quickmail.rs +++ b/command-signatures/src/generators/quickmail.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "template_listall", Generator::script( CommandBuilder::single_command("quickmail template listall"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/r.rs b/command-signatures/src/generators/r.rs index 43df12a6..54e6063b 100644 --- a/command-signatures/src/generators/r.rs +++ b/command-signatures/src/generators/r.rs @@ -1,12 +1,17 @@ -use super::fig_parse; +use super::{output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("r").add_generator( - "rscript_libpaths", - Generator::script( - CommandBuilder::single_command("Rscript -e '.libPaths()'"), - fig_parse::lines, - ), - ) + CommandSignatureGenerators::new("r") + .add_generator( + "rscript_libpaths", + Generator::script( + CommandBuilder::single_command("Rscript -e '.libPaths()'"), + output_parsers::named_lines, + ), + ) + .add_filter("filter-r", template_filters::r()) + .add_filter("filter-rd", template_filters::rd()) + .add_filter("filter-r-src", template_filters::r_src()) + .add_filter("filter-r-archive", template_filters::r_archive()) } diff --git a/command-signatures/src/generators/rancher.rs b/command-signatures/src/generators/rancher.rs index 94811388..23816826 100644 --- a/command-signatures/src/generators/rancher.rs +++ b/command-signatures/src/generators/rancher.rs @@ -1,12 +1,14 @@ -use super::fig_parse; +use super::{output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("rancher").add_generator( - "server", - Generator::script( - CommandBuilder::single_command("rancher server ls"), - fig_parse::lines, - ), - ) + CommandSignatureGenerators::new("rancher") + .add_generator( + "server", + Generator::script( + CommandBuilder::single_command("rancher server ls"), + output_parsers::named_lines, + ), + ) + .add_filter("filter-json-yaml", template_filters::json_yaml()) } diff --git a/command-signatures/src/generators/rclone.rs b/command-signatures/src/generators/rclone.rs index 17ead206..fbfd89cb 100644 --- a/command-signatures/src/generators/rclone.rs +++ b/command-signatures/src/generators/rclone.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "listremotes", Generator::script( CommandBuilder::single_command("rclone listremotes"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/redwood.rs b/command-signatures/src/generators/redwood.rs index 78a65b31..9fb9b656 100644 --- a/command-signatures/src/generators/redwood.rs +++ b/command-signatures/src/generators/redwood.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -8,7 +8,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "until [[ -f redwood.toml ]] || [[ $PWD = '/' ]]; do cd ..; done; ls -1p scripts/", ), - fig_parse::lines, + output_parsers::redwood_scripts, ), ) } diff --git a/command-signatures/src/generators/robot.rs b/command-signatures/src/generators/robot.rs index bc0c719d..2b88db06 100644 --- a/command-signatures/src/generators/robot.rs +++ b/command-signatures/src/generators/robot.rs @@ -1,14 +1,35 @@ -use super::fig_parse; +use super::{fig_token, output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("robot").add_generator( - "for_i_in_robot", - Generator::script( - CommandBuilder::single_command( - r#"for i in $(find -E . -regex ".*.robot" -type f); do cat -s $i ; done"#, + CommandSignatureGenerators::new("robot") + .add_generator( + "for_i_in_robot", + Generator::script( + CommandBuilder::single_command( + r#"for i in $(find -E . -regex ".*.robot" -type f); do cat -s $i ; done"#, + ), + output_parsers::robot_tags, ), - fig_parse::lines, - ), - ) + ) + .add_generator( + "test_cases", + Generator::script( + CommandBuilder::single_command( + r#"for i in $(find -E . -regex ".*.robot" -type f); do cat -s $i ; done"#, + ), + output_parsers::robot_test_cases, + ), + ) + .add_generator( + "variables", + Generator::command_from_tokens( + fig_token::robot_variables, + output_parsers::robot_variables, + ), + ) + .add_filter("filter-robot", template_filters::robot()) + .add_filter("filter-xml", template_filters::xml()) + .add_filter("filter-py-yaml", template_filters::py_yaml()) + .add_filter("filter-zip", template_filters::zip()) } diff --git a/command-signatures/src/generators/rollup.rs b/command-signatures/src/generators/rollup.rs new file mode 100644 index 00000000..87a8b58b --- /dev/null +++ b/command-signatures/src/generators/rollup.rs @@ -0,0 +1,7 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("rollup") + .add_filter("filter-config-js", template_filters::config_js()) +} diff --git a/command-signatures/src/generators/rscript.rs b/command-signatures/src/generators/rscript.rs new file mode 100644 index 00000000..b451fd1d --- /dev/null +++ b/command-signatures/src/generators/rscript.rs @@ -0,0 +1,6 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("rscript").add_filter("filter-r", template_filters::r()) +} diff --git a/command-signatures/src/generators/rush.rs b/command-signatures/src/generators/rush.rs index 687d34af..fbb578e6 100644 --- a/command-signatures/src/generators/rush.rs +++ b/command-signatures/src/generators/rush.rs @@ -1,14 +1,22 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("rush").add_generator( - "until_rush_json_do_cd", - Generator::script( - CommandBuilder::single_command( - "until [[ -f rush.json ]] || [[ $PWD = '/' ]]; do cd ..; done; cat rush.json", + CommandSignatureGenerators::new("rush") + .add_generator( + "until_rush_json_do_cd", + Generator::script( + CommandBuilder::single_command( + "until [[ -f rush.json ]] || [[ $PWD = '/' ]]; do cd ..; done; cat rush.json", + ), + output_parsers::json_rush_projects, ), - fig_parse::lines, - ), - ) + ) + .add_generator( + "npms_search", + Generator::command_from_tokens( + super::fig_token::npms_search, + output_parsers::npms_search_results, + ), + ) } diff --git a/command-signatures/src/generators/rushx.rs b/command-signatures/src/generators/rushx.rs index 08b3dec0..5941bf0e 100644 --- a/command-signatures/src/generators/rushx.rs +++ b/command-signatures/src/generators/rushx.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -8,7 +8,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "until [[ -f package.json ]] || [[ $PWD = '/' ]]; do cd ..; done; cat package.json", ), - fig_parse::lines, + output_parsers::json_script_keys, ), ) } diff --git a/command-signatures/src/generators/rustup.rs b/command-signatures/src/generators/rustup.rs index 66ebb6e1..ebfa6f46 100644 --- a/command-signatures/src/generators/rustup.rs +++ b/command-signatures/src/generators/rustup.rs @@ -1,13 +1,13 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { CommandSignatureGenerators::new("rustup") .add_generator( - "find_docs_s_index_html", + "rustup_docs", Generator::script( CommandBuilder::single_command(r#"find $(rustup docs --path | sed -e "s|index\.html|std|") $(rustup docs --path | sed -e "s|index\.html|alloc|") $(rustup docs --path | sed -e "s|index\.html|core|") | grep "\.html" | sed -E -e "s|^(.*)/html/||" -e "s|\.html||" -e "s|/|::|g" -e "s/constant\.|trait\.|struct\.|macro\.|fn\.|keyword\.|primitive\.|type\.|enum\.|union\.|traitalias\.|::index$|^(.*)::all$//" -e "/^$/d""#), - fig_parse::lines, + output_parsers::lines, ), ) } diff --git a/command-signatures/src/generators/scc.rs b/command-signatures/src/generators/scc.rs index 3b6e2c63..20abda5b 100644 --- a/command-signatures/src/generators/scc.rs +++ b/command-signatures/src/generators/scc.rs @@ -1,12 +1,17 @@ -use super::fig_parse; +use super::{fig_token, output_parsers}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("scc").add_generator( - "completions", - Generator::script( - CommandBuilder::single_command("scc --languages"), - fig_parse::lines, - ), - ) + CommandSignatureGenerators::new("scc") + .add_generator( + "completions", + Generator::script( + CommandBuilder::single_command("scc --languages"), + output_parsers::scc_languages, + ), + ) + .add_generator( + "format_multi", + Generator::command_from_tokens(fig_token::scc_output_paths, output_parsers::lines), + ) } diff --git a/command-signatures/src/generators/sftp.rs b/command-signatures/src/generators/sftp.rs index 9af58fc9..4d054b71 100644 --- a/command-signatures/src/generators/sftp.rs +++ b/command-signatures/src/generators/sftp.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "cat_ssh_config", Generator::script( CommandBuilder::single_command("cat ~/.ssh/config"), - fig_parse::lines, + output_parsers::ssh_hosts, ), ) .add_generator( "cat_ssh_known_hosts", - Generator::script( - CommandBuilder::single_command("cat ~/.ssh/known_hosts"), - fig_parse::lines, + Generator::command_from_tokens( + super::fig_token::known_hosts_file, + output_parsers::ssh_known_hosts, ), ) } diff --git a/command-signatures/src/generators/shortcuts.rs b/command-signatures/src/generators/shortcuts.rs index 38e88e02..dd356cc5 100644 --- a/command-signatures/src/generators/shortcuts.rs +++ b/command-signatures/src/generators/shortcuts.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::{output_parsers, template_filters}; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,15 @@ pub fn generator() -> CommandSignatureGenerators { "list", Generator::script( CommandBuilder::single_command("shortcuts list"), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( "list_shortcuts", Generator::script( CommandBuilder::single_command("shortcuts list --folders"), - fig_parse::lines, + output_parsers::named_lines, ), ) + .add_filter("filter-shortcut", template_filters::shortcut()) } diff --git a/command-signatures/src/generators/softwareupdate.rs b/command-signatures/src/generators/softwareupdate.rs index 5d34c12e..f16486af 100644 --- a/command-signatures/src/generators/softwareupdate.rs +++ b/command-signatures/src/generators/softwareupdate.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "completions", Generator::script( CommandBuilder::single_command("softwareupdate --list"), - fig_parse::lines, + output_parsers::softwareupdate_labels, ), ) } diff --git a/command-signatures/src/generators/sqlite3.rs b/command-signatures/src/generators/sqlite3.rs new file mode 100644 index 00000000..6290e16c --- /dev/null +++ b/command-signatures/src/generators/sqlite3.rs @@ -0,0 +1,7 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("sqlite3") + .add_filter("filter-sqlite", template_filters::sqlite()) +} diff --git a/command-signatures/src/generators/ssh.rs b/command-signatures/src/generators/ssh.rs index 15bc7274..e3c1a409 100644 --- a/command-signatures/src/generators/ssh.rs +++ b/command-signatures/src/generators/ssh.rs @@ -1,7 +1,5 @@ use super::common; -use warp_completion_metadata::{ - CommandBuilder, CommandSignatureGenerators, Generator, GeneratorResultsCollector, Suggestion, -}; +use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { CommandSignatureGenerators::new("ssh") @@ -11,13 +9,7 @@ pub fn generator() -> CommandSignatureGenerators { "known_hosts", Generator::script( CommandBuilder::single_command("cat ~/.ssh/known_hosts"), - |output| { - output - .lines() - .filter_map(|line| line.split_once(' ').map(|(first, _)| first)) - .map(|known_host| Suggestion::with_description(known_host, "SSH Host")) - .collect_unordered_results() - }, + super::output_parsers::ssh_known_hosts, ), ) } diff --git a/command-signatures/src/generators/st2.rs b/command-signatures/src/generators/st2.rs new file mode 100644 index 00000000..8da08e98 --- /dev/null +++ b/command-signatures/src/generators/st2.rs @@ -0,0 +1,9 @@ +use super::{fig_token, output_parsers}; +use warp_completion_metadata::{CommandSignatureGenerators, Generator}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("st2").add_generator( + "users_or_groups", + Generator::command_from_tokens(fig_token::chown_dscl, output_parsers::lines), + ) +} diff --git a/command-signatures/src/generators/stepzen.rs b/command-signatures/src/generators/stepzen.rs index 3c5ece01..dbd13772 100644 --- a/command-signatures/src/generators/stepzen.rs +++ b/command-signatures/src/generators/stepzen.rs @@ -1,22 +1,22 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { CommandSignatureGenerators::new("stepzen") .add_generator( - "curl_https_api_github_com_repos_steprz_stepzen_schemas_contents", + "github_schemas", Generator::script( CommandBuilder::single_command( "curl https://api.github.com/repos/steprz/stepzen-schemas/contents", ), - fig_parse::lines, + output_parsers::stepzen_github_dirs, ), ) .add_generator( "list_schemas", Generator::script( CommandBuilder::single_command("stepzen list schemas"), - fig_parse::lines, + output_parsers::stepzen_schema_names, ), ) } diff --git a/command-signatures/src/generators/subl.rs b/command-signatures/src/generators/subl.rs new file mode 100644 index 00000000..f1bdb764 --- /dev/null +++ b/command-signatures/src/generators/subl.rs @@ -0,0 +1,7 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("subl") + .add_filter("filter-sublime", template_filters::sublime()) +} diff --git a/command-signatures/src/generators/sysctl.rs b/command-signatures/src/generators/sysctl.rs index eb21dba9..9ecf1f6b 100644 --- a/command-signatures/src/generators/sysctl.rs +++ b/command-signatures/src/generators/sysctl.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "completions", Generator::script( CommandBuilder::single_command("sysctl -A -N"), - fig_parse::lines, + output_parsers::desc_variable, ), ) } diff --git a/command-signatures/src/generators/tailscale.rs b/command-signatures/src/generators/tailscale.rs index 7127e2dd..ad4321b3 100644 --- a/command-signatures/src/generators/tailscale.rs +++ b/command-signatures/src/generators/tailscale.rs @@ -1,12 +1,20 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("tailscale").add_generator( - "status", - Generator::script( - CommandBuilder::single_command("tailscale status --json"), - fig_parse::lines, - ), - ) + CommandSignatureGenerators::new("tailscale") + .add_generator( + "status", + Generator::script( + CommandBuilder::single_command("tailscale status --json"), + output_parsers::tailscale_peers, + ), + ) + .add_generator( + "peers_colon", + Generator::script( + CommandBuilder::single_command("tailscale status --json"), + output_parsers::tailscale_peers_colon, + ), + ) } diff --git a/command-signatures/src/generators/tccutil.rs b/command-signatures/src/generators/tccutil.rs index 8da14b42..d11f76a0 100644 --- a/command-signatures/src/generators/tccutil.rs +++ b/command-signatures/src/generators/tccutil.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,7 +7,7 @@ pub fn generator() -> CommandSignatureGenerators { "mdfind_applications_while_read", Generator::script( CommandBuilder::single_command(r#"mdfind kMDItemContentTypeTree=com.apple.application-bundle -onlyin /Applications | while read line; do echo $(mdls -name kMDItemCFBundleIdentifier -r "$line") $line; done"#), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/template_filters.rs b/command-signatures/src/generators/template_filters.rs new file mode 100644 index 00000000..ab6d1e10 --- /dev/null +++ b/command-signatures/src/generators/template_filters.rs @@ -0,0 +1,341 @@ +use warp_completion_metadata::{ + Importance, Order, PathSuggestionType, Priority, Suggestion, TemplateFilter, +}; + +pub fn py() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["py"], Some(76))) +} + +pub fn yml_yaml() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["yml", "yaml"], None) + }) +} + +pub fn envrc() -> TemplateFilter { + TemplateFilter(|mut suggestion, path_type| { + if path_type.is_folder() { + return Some(suggestion); + } + let name = suggestion.exact_string.as_str(); + let is_envrc = name == ".envrc" + || name == ".envrc/" + || name.ends_with("/.envrc") + || name.ends_with("/.envrc/"); + if is_envrc { + suggestion.priority = Priority::Global(Importance::More(Order(76))); + Some(suggestion) + } else { + None + } + }) +} + +pub fn tsconfig_json() -> TemplateFilter { + TemplateFilter(|mut suggestion, path_type| { + let name = suggestion.exact_string.as_str(); + let is_json = name.ends_with(".json") || name.ends_with(".json/"); + if path_type.is_folder() || is_json { + if name.ends_with("tsconfig.json") || name.ends_with("tsconfig.json/") { + suggestion.priority = Priority::Global(Importance::More(Order(100))); + } else if is_json { + suggestion.priority = Priority::Global(Importance::More(Order(76))); + } + Some(suggestion) + } else { + None + } + }) +} + +pub fn xcodeproj() -> TemplateFilter { + TemplateFilter(|mut suggestion, _path_type| { + if suggestion.exact_string.ends_with(".xcodeproj/") + || suggestion.exact_string.ends_with(".xcodeproj") + { + suggestion.priority = Priority::Global(Importance::More(Order(76))); + } + Some(suggestion) + }) +} + +pub fn rs() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["rs"], None)) +} + +pub fn cargo_toml() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_equals(suggestion, path_type, &["Cargo.toml"]) + }) +} + +pub fn cargo_lock() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_equals(suggestion, path_type, &["Cargo.lock"]) + }) +} + +pub fn rustfmt_toml() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_equals(suggestion, path_type, &["rustfmt.toml"]) + }) +} + +pub fn js_ts_family() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext( + suggestion, + path_type, + &["ts", "tsx", "js", "jsx", "mjs", "cjs"], + None, + ) + }) +} + +pub fn deployctl() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext( + suggestion, + path_type, + &["js", "mjs", "jsx", "mjsx", "ts", "mts", "tsx", "mtsx"], + None, + ) + }) +} + +pub fn exs() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["exs"], Some(76)) + }) +} + +pub fn java_class() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["java", "class"], None) + }) +} + +pub fn jar() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["jar"], None)) +} + +pub fn jl() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["jl"], Some(76))) +} + +pub fn dylib_so_dll() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["dylib", "so", "dll"], Some(76)) + }) +} + +pub fn json() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["json"], None)) +} + +pub fn yaml() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["yaml"], None)) +} + +pub fn yaml_json() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["yaml", "json"], None) + }) +} + +pub fn json_yaml() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["json", "yaml"], None) + }) +} + +pub fn scpt() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["scpt", "scptd"], Some(76)) + }) +} + +pub fn pdf() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["pdf"], None)) +} + +pub fn robot() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["robot"], Some(76)) + }) +} + +pub fn xml() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["xml"], None)) +} + +pub fn py_yaml() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["py", "yaml"], None) + }) +} + +pub fn zip() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["zip"], None)) +} + +pub fn config_js() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + if path_type.is_folder() { + return Some(suggestion); + } + suggestion + .exact_string + .ends_with("config.js") + .then_some(suggestion) + }) +} + +pub fn r_src() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext( + suggestion, + path_type, + &["c", "cc", "cpp", "m", "mm", "M", "f", "f90", "f95"], + None, + ) + }) +} + +pub fn r_archive() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + if path_type.is_folder() { + return Some(suggestion); + } + let name = suggestion.exact_string.to_ascii_lowercase(); + ["tar", "tar.gz", "tzr.bz2", "tar.xz", "tgz"] + .iter() + .any(|ext| name.ends_with(&format!(".{ext}")) || name.ends_with(&format!(".{ext}/"))) + .then_some(suggestion) + }) +} + +pub fn rd() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["rd"], Some(76))) +} + +pub fn r() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["r"], Some(76))) +} + +pub fn shortcut() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["shortcut"], None) + }) +} + +pub fn sqlite() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext( + suggestion, + path_type, + &["sql", "sqlite", "sqlite3", "db"], + None, + ) + }) +} + +pub fn sublime() -> TemplateFilter { + TemplateFilter(|mut suggestion, path_type| { + if path_type.is_folder() { + return Some(suggestion); + } + let name = suggestion.exact_string.as_str(); + let matched = name.ends_with(".sublime-project") + || name.ends_with(".sublime-workspace") + || name.ends_with(".sublime-project/") + || name.ends_with(".sublime-workspace/"); + if matched { + suggestion.priority = Priority::Global(Importance::More(Order(76))); + Some(suggestion) + } else { + None + } + }) +} + +pub fn ts() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["ts"], Some(76))) +} + +pub fn ts_tsx() -> TemplateFilter { + TemplateFilter(|mut suggestion, path_type| { + if path_type.is_folder() { + return Some(suggestion); + } + let name = suggestion.exact_string.to_ascii_lowercase(); + let matched = name.ends_with(".ts") + || name.ends_with(".tsx") + || name.ends_with(".ts/") + || name.ends_with(".tsx/"); + if matched { + suggestion.priority = Priority::Global(Importance::More(Order(76))); + Some(suggestion) + } else { + None + } + }) +} + +pub fn vsix() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["vsix"], None)) +} + +pub fn wasm() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| folders_or_ext(suggestion, path_type, &["wasm"], None)) +} + +pub fn podspec() -> TemplateFilter { + TemplateFilter(|suggestion, path_type| { + folders_or_ext(suggestion, path_type, &["podspec"], None) + }) +} + +fn folders_or_ext( + mut suggestion: Suggestion, + path_type: PathSuggestionType, + extensions: &[&str], + file_priority: Option, +) -> Option { + if path_type.is_folder() { + return Some(suggestion); + } + let name = suggestion.exact_string.to_ascii_lowercase(); + let matched = extensions.iter().any(|ext| { + let ext = ext.to_ascii_lowercase(); + name.ends_with(&format!(".{ext}")) || name.ends_with(&format!(".{ext}/")) + }); + if matched { + if let Some(priority) = file_priority { + suggestion.priority = Priority::Global(Importance::More(Order(priority))); + } + Some(suggestion) + } else { + None + } +} + +fn folders_or_equals( + suggestion: Suggestion, + path_type: PathSuggestionType, + names: &[&str], +) -> Option { + if path_type.is_folder() { + return Some(suggestion); + } + let value = suggestion.exact_string.as_str(); + names + .iter() + .any(|name| { + value == *name + || value.ends_with(&format!("/{name}")) + || value.ends_with(&format!("{name}/")) + || value.ends_with(name) + }) + .then_some(suggestion) +} diff --git a/command-signatures/src/generators/terragrunt.rs b/command-signatures/src/generators/terragrunt.rs index 51870dc1..a442ee89 100644 --- a/command-signatures/src/generators/terragrunt.rs +++ b/command-signatures/src/generators/terragrunt.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "state_list", Generator::script( CommandBuilder::single_command("terragrunt state list"), - fig_parse::lines, + output_parsers::desc_address, ), ) .add_generator( "workspace_list", Generator::script( CommandBuilder::single_command("terragrunt workspace list"), - fig_parse::lines, + output_parsers::desc_workspace, ), ) } diff --git a/command-signatures/src/generators/tfenv.rs b/command-signatures/src/generators/tfenv.rs index 5ee63f98..0e4246d1 100644 --- a/command-signatures/src/generators/tfenv.rs +++ b/command-signatures/src/generators/tfenv.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "list", Generator::script( CommandBuilder::single_command("tfenv list"), - fig_parse::lines, + output_parsers::desc_version, ), ) .add_generator( "list_remote", Generator::script( CommandBuilder::single_command("tfenv list-remote"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/tfsec.rs b/command-signatures/src/generators/tfsec.rs index 0881beb1..fb9fb131 100644 --- a/command-signatures/src/generators/tfsec.rs +++ b/command-signatures/src/generators/tfsec.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "terraform_workspace_list", Generator::script( CommandBuilder::single_command("terraform workspace list"), - fig_parse::lines, + output_parsers::desc_terraform_workspace, ), ) } diff --git a/command-signatures/src/generators/tokei.rs b/command-signatures/src/generators/tokei.rs index 62deed07..9fa960b7 100644 --- a/command-signatures/src/generators/tokei.rs +++ b/command-signatures/src/generators/tokei.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "completions", Generator::script( CommandBuilder::single_command("tokei --languages"), - fig_parse::lines, + output_parsers::lines, ), ) } diff --git a/command-signatures/src/generators/trex.rs b/command-signatures/src/generators/trex.rs index 5dd5ee95..4a5c23ba 100644 --- a/command-signatures/src/generators/trex.rs +++ b/command-signatures/src/generators/trex.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,14 +7,14 @@ pub fn generator() -> CommandSignatureGenerators { "cat_import_map_json", Generator::script( CommandBuilder::single_command("cat import_map.json"), - fig_parse::lines, + output_parsers::trex_imports, ), ) .add_generator( "cat_run_json", Generator::script( CommandBuilder::single_command("cat run.json"), - fig_parse::lines, + output_parsers::trex_scripts, ), ) } diff --git a/command-signatures/src/generators/trivy.rs b/command-signatures/src/generators/trivy.rs new file mode 100644 index 00000000..047c9354 --- /dev/null +++ b/command-signatures/src/generators/trivy.rs @@ -0,0 +1,27 @@ +use super::{fig_token, output_parsers}; +use warp_completion_metadata::{CommandSignatureGenerators, Generator}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("trivy") + .add_generator( + "severity_remaining", + Generator::command_from_tokens( + fig_token::trivy_severity_remaining, + output_parsers::lines, + ), + ) + .add_generator( + "scanners_remaining", + Generator::command_from_tokens( + fig_token::trivy_scanners_remaining, + output_parsers::lines, + ), + ) + .add_generator( + "pkg_types_remaining", + Generator::command_from_tokens( + fig_token::trivy_pkg_types_remaining, + output_parsers::lines, + ), + ) +} diff --git a/command-signatures/src/generators/ts_node.rs b/command-signatures/src/generators/ts_node.rs new file mode 100644 index 00000000..abdfe8a0 --- /dev/null +++ b/command-signatures/src/generators/ts_node.rs @@ -0,0 +1,8 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("ts-node") + .add_filter("filter-tsconfig", template_filters::tsconfig_json()) + .add_filter("filter-ts-tsx", template_filters::ts_tsx()) +} diff --git a/command-signatures/src/generators/tsc.rs b/command-signatures/src/generators/tsc.rs new file mode 100644 index 00000000..33b32094 --- /dev/null +++ b/command-signatures/src/generators/tsc.rs @@ -0,0 +1,6 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("tsc").add_filter("filter-ts", template_filters::ts()) +} diff --git a/command-signatures/src/generators/turbo.rs b/command-signatures/src/generators/turbo.rs index f19e85ca..9990d3b3 100644 --- a/command-signatures/src/generators/turbo.rs +++ b/command-signatures/src/generators/turbo.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -9,7 +9,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "git --no-optional-locks branch -a --no-color --sort=-committerdate", ), - fig_parse::lines, + crate::generators::git::post_process_branches, ), ) .add_generator( @@ -18,7 +18,7 @@ pub fn generator() -> CommandSignatureGenerators { CommandBuilder::single_command( "until [[ ( -f turbo.json || $PWD = '/' ) ]]; do cd ..; done; cat turbo.json", ), - fig_parse::lines, + output_parsers::turbo_pipeline, ), ) } diff --git a/command-signatures/src/generators/vite.rs b/command-signatures/src/generators/vite.rs index 15681a22..f797ee15 100644 --- a/command-signatures/src/generators/vite.rs +++ b/command-signatures/src/generators/vite.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "ls", Generator::script( CommandBuilder::single_command(r"\ls -l1A.env.*"), - fig_parse::lines, + output_parsers::lines, ), ) } diff --git a/command-signatures/src/generators/vr.rs b/command-signatures/src/generators/vr.rs index e822c96f..33fc5dcb 100644 --- a/command-signatures/src/generators/vr.rs +++ b/command-signatures/src/generators/vr.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "completions", Generator::script( CommandBuilder::single_command("NO_COLOR=1 vr"), - fig_parse::lines, + output_parsers::second_whitespace_token, ), ) } diff --git a/command-signatures/src/generators/vsce.rs b/command-signatures/src/generators/vsce.rs index bffaba81..229d1237 100644 --- a/command-signatures/src/generators/vsce.rs +++ b/command-signatures/src/generators/vsce.rs @@ -1,14 +1,16 @@ -use super::fig_parse; +use super::template_filters; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("vsce").add_generator( - "git_branch", - Generator::script( - CommandBuilder::single_command( - "git --no-optional-locks branch -a --no-color --sort=-committerdate", + CommandSignatureGenerators::new("vsce") + .add_generator( + "git_branch", + Generator::script( + CommandBuilder::single_command( + "git --no-optional-locks branch -a --no-color --sort=-committerdate", + ), + crate::generators::git::post_process_branches, ), - fig_parse::lines, - ), - ) + ) + .add_filter("filter-vsix", template_filters::vsix()) } diff --git a/command-signatures/src/generators/vultr_cli.rs b/command-signatures/src/generators/vultr_cli.rs index 252d14e6..ec6b5952 100644 --- a/command-signatures/src/generators/vultr_cli.rs +++ b/command-signatures/src/generators/vultr_cli.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "instance_list", Generator::script( CommandBuilder::single_command("vultr-cli instance list"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/wasm_bindgen.rs b/command-signatures/src/generators/wasm_bindgen.rs new file mode 100644 index 00000000..d5d433c0 --- /dev/null +++ b/command-signatures/src/generators/wasm_bindgen.rs @@ -0,0 +1,7 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("wasm-bindgen") + .add_filter("filter-wasm", template_filters::wasm()) +} diff --git a/command-signatures/src/generators/watson.rs b/command-signatures/src/generators/watson.rs index e15c0d2e..fed2c9d4 100644 --- a/command-signatures/src/generators/watson.rs +++ b/command-signatures/src/generators/watson.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,21 +7,21 @@ pub fn generator() -> CommandSignatureGenerators { "log", Generator::script( CommandBuilder::single_command("watson log --json --reverse"), - fig_parse::lines, + output_parsers::json_string_array, ), ) .add_generator( "projects", Generator::script( CommandBuilder::single_command("watson projects"), - fig_parse::lines, + output_parsers::named_lines, ), ) .add_generator( "tags", Generator::script( CommandBuilder::single_command("watson tags"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/wd.rs b/command-signatures/src/generators/wd.rs index 88823334..955b46aa 100644 --- a/command-signatures/src/generators/wd.rs +++ b/command-signatures/src/generators/wd.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "cat_warprc", Generator::script( CommandBuilder::single_command("cat ~/.warprc"), - fig_parse::lines, + output_parsers::desc_warp_point, ), ) } diff --git a/command-signatures/src/generators/wifi_password.rs b/command-signatures/src/generators/wifi_password.rs index e08dff1a..2e30d598 100644 --- a/command-signatures/src/generators/wifi_password.rs +++ b/command-signatures/src/generators/wifi_password.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -7,7 +7,7 @@ pub fn generator() -> CommandSignatureGenerators { "networksetup_wi_fi_getline_print_networksetup", Generator::script( CommandBuilder::single_command("networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -listpreferredwirelessnetworks"), - fig_parse::lines, + output_parsers::wifi_networks, ), ) } diff --git a/command-signatures/src/generators/xcodeproj.rs b/command-signatures/src/generators/xcodeproj.rs new file mode 100644 index 00000000..8af28095 --- /dev/null +++ b/command-signatures/src/generators/xcodeproj.rs @@ -0,0 +1,7 @@ +use super::template_filters; +use warp_completion_metadata::CommandSignatureGenerators; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("xcodeproj") + .add_filter("filter-xcodeproj", template_filters::xcodeproj()) +} diff --git a/command-signatures/src/generators/yo.rs b/command-signatures/src/generators/yo.rs index 527e1e1d..830eac12 100644 --- a/command-signatures/src/generators/yo.rs +++ b/command-signatures/src/generators/yo.rs @@ -1,4 +1,4 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { @@ -6,7 +6,7 @@ pub fn generator() -> CommandSignatureGenerators { "completions", Generator::script( CommandBuilder::single_command("yo --generators"), - fig_parse::lines, + output_parsers::named_lines, ), ) } diff --git a/command-signatures/src/generators/youtube_dl.rs b/command-signatures/src/generators/youtube_dl.rs index fcf7d9fa..c45264fc 100644 --- a/command-signatures/src/generators/youtube_dl.rs +++ b/command-signatures/src/generators/youtube_dl.rs @@ -1,9 +1,20 @@ -use super::fig_parse; +use super::output_parsers; use warp_completion_metadata::{CommandBuilder, CommandSignatureGenerators, Generator}; pub fn generator() -> CommandSignatureGenerators { - CommandSignatureGenerators::new("youtube-dl").add_generator( - "pbpaste", - Generator::script(CommandBuilder::single_command("pbpaste"), fig_parse::lines), - ) + CommandSignatureGenerators::new("youtube-dl") + .add_generator( + "pbpaste", + Generator::script( + CommandBuilder::single_command("pbpaste"), + output_parsers::youtube_clipboard_url, + ), + ) + .add_generator( + "flat_playlist", + Generator::command_from_tokens( + super::fig_token::youtube_dl_flat_playlist, + output_parsers::youtube_dl_flat_playlist, + ), + ) }