Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 7 additions & 28 deletions command-signatures/json/pass.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"args": {
"name": "pass-name",
"description": "The password you want to show",
"generators": {
"script": "function(){return\"grep -r -l '' $HOME/.password-store --exclude-dir=.git\"}",
"postProcess": "_NuFrRa_s=>s.split(`\n`).map(o=>({name:o.split(\".password-store/\").pop().replace(\".gpg\",\"\"),icon:\"\\u{1F510}\"}))"
}
"generatorName": "entries"
},
"options": [
{
Expand Down Expand Up @@ -102,10 +99,7 @@
{
"name": "old-path",
"description": "The old password name or directory",
"generators": {
"script": "function(){return\"grep -r -l '' $HOME/.password-store --exclude-dir=.git\"}",
"postProcess": "_NuFrRa_s=>s.split(`\n`).map(o=>({name:o.split(\".password-store/\").pop().replace(\".gpg\",\"\"),icon:\"\\u{1F510}\"}))"
}
"generatorName": "entries"
},
{
"name": "new-path",
Expand All @@ -129,10 +123,7 @@
{
"name": "old-path",
"description": "The old password name or directory",
"generators": {
"script": "function(){return\"grep -r -l '' $HOME/.password-store --exclude-dir=.git\"}",
"postProcess": "_NuFrRa_s=>s.split(`\n`).map(o=>({name:o.split(\".password-store/\").pop().replace(\".gpg\",\"\"),icon:\"\\u{1F510}\"}))"
}
"generatorName": "entries"
},
{
"name": "new-path",
Expand All @@ -155,10 +146,7 @@
"args": {
"name": "pass-name",
"description": "The password name",
"generators": {
"script": "function(){return\"grep -r -l '' $HOME/.password-store --exclude-dir=.git\"}",
"postProcess": "_NuFrRa_s=>s.split(`\n`).map(o=>({name:o.split(\".password-store/\").pop().replace(\".gpg\",\"\"),icon:\"\\u{1F510}\"}))"
}
"generatorName": "entries"
},
"options": [
{
Expand Down Expand Up @@ -232,10 +220,7 @@
"name": "password sub-directory",
"description": "The password sub directory you want to list",
"isOptional": true,
"generators": {
"script": "function(){return\"ls -dR1a $HOME/.password-store/*/\"}",
"postProcess": "_NuFrRa_s=>s.split(`\n`).map(o=>({name:o.split(\".password-store/\").pop(),icon:\"\\u{1F4C1}\"}))"
}
"generatorName": "directories"
}
},
{
Expand All @@ -252,10 +237,7 @@
"args": {
"name": "pass-name",
"description": "The password you want to show",
"generators": {
"script": "function(){return\"grep -r -l '' $HOME/.password-store --exclude-dir=.git\"}",
"postProcess": "_NuFrRa_s=>s.split(`\n`).map(o=>({name:o.split(\".password-store/\").pop().replace(\".gpg\",\"\"),icon:\"\\u{1F510}\"}))"
}
"generatorName": "entries"
},
"options": [
{
Expand All @@ -280,10 +262,7 @@
"args": {
"name": "pass-name",
"description": "The password you want to edit",
"generators": {
"script": "function(){return\"grep -r -l '' $HOME/.password-store --exclude-dir=.git\"}",
"postProcess": "_NuFrRa_s=>s.split(`\n`).map(o=>({name:o.split(\".password-store/\").pop().replace(\".gpg\",\"\"),icon:\"\\u{1F510}\"}))"
}
"generatorName": "entries"
}
},
{
Expand Down
2 changes: 2 additions & 0 deletions command-signatures/src/generators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ mod node;
mod npm;
mod nx;
mod pacman;
mod pass;
mod phpunit_watcher;
mod pip;
mod powershell;
Expand Down Expand Up @@ -74,6 +75,7 @@ pub fn dynamic_command_signature_data() -> HashMap<String, DynamicCompletionData
npm::yarn_generators(),
nx::generator(),
pacman::generator(),
pass::generator(),
phpunit_watcher::generator(),
pip::generator(),
pip::pip3_generator(),
Expand Down
40 changes: 40 additions & 0 deletions command-signatures/src/generators/pass.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use warp_completion_metadata::{
CommandBuilder, CommandSignatureGenerators, Generator, GeneratorResultsCollector, Suggestion,
};

pub fn generator() -> CommandSignatureGenerators {
// The shell commands cd into the password store directory so that `find`
// outputs paths relative to it. sed then strips the leading `./` and,
// for entries, the trailing `.gpg` extension.
CommandSignatureGenerators::new("pass")
.add_generator(
"entries",
Generator::script(
CommandBuilder::single_command(
"(cd \"${PASSWORD_STORE_DIR:-$HOME/.password-store}\" 2>/dev/null && find . -name '*.gpg' ! -path '*/.git/*' | sed 's|^\\./||;s|\\.gpg$||' | sort)",
),
|output| {
output
.lines()
.filter(|line| !line.is_empty())
.map(|line| Suggestion::with_description(line.trim(), "Password entry"))
.collect_unordered_results()
},
),
)
.add_generator(
"directories",
Generator::script(
CommandBuilder::single_command(
"(cd \"${PASSWORD_STORE_DIR:-$HOME/.password-store}\" 2>/dev/null && find . -type d ! -name '.git' ! -path '*/.git/*' -mindepth 1 | sed 's|^\\./||' | sort)",
),
|output| {
output
.lines()
.filter(|line| !line.is_empty())
.map(|line| Suggestion::with_description(line.trim(), "Password directory"))
.collect_unordered_results()
},
),
)
}
Loading