From f8adffd3ff8a5dbd4069eaecf6ec4874e1f5121c Mon Sep 17 00:00:00 2001 From: Denis Isidoro Date: Thu, 15 Apr 2021 11:00:04 -0300 Subject: [PATCH] Remove support for alfred (#509) --- .github/workflows/cd.yml | 18 - Cargo.lock | 2 +- Cargo.toml | 2 +- alfred/alfred0.bash | 10 - alfred/alfred1.bash | 14 - alfred/alfred2.bash | 10 - alfred/alfred3.bash | 7 - alfred/icon.png | Bin 3242 -> 0 bytes alfred/info.plist | 1039 -------------------------------------- docs/alfred.md | 9 +- scripts/action | 17 - scripts/fix | 2 - src/cmds/alfred.rs | 115 ----- src/cmds/mod.rs | 1 - src/handler.rs | 18 +- src/structures/config.rs | 18 - src/writer/alfred.rs | 80 --- src/writer/mod.rs | 1 - 18 files changed, 11 insertions(+), 1352 deletions(-) delete mode 100755 alfred/alfred0.bash delete mode 100755 alfred/alfred1.bash delete mode 100755 alfred/alfred2.bash delete mode 100755 alfred/alfred3.bash delete mode 100644 alfred/icon.png delete mode 100644 alfred/info.plist delete mode 100644 src/cmds/alfred.rs delete mode 100644 src/writer/alfred.rs diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 4a76091..3a37ffd 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -7,24 +7,6 @@ on: jobs: - alfred: - name: Publish Alfred workflow - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Zip - run: scripts/action workflow - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - name: Upload workflow to release - uses: svenstaro/upload-release-action@v1-release - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/workflow/navi.zip - tag: ${{ github.ref }} - asset_name: navi-${{ steps.get_version.outputs.VERSION }}.alfredworkflow - binary: name: Publish ${{ matrix.target }} runs-on: ${{ matrix.os }} diff --git a/Cargo.lock b/Cargo.lock index dbc2046..2a01866 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -308,7 +308,7 @@ dependencies = [ [[package]] name = "navi" -version = "2.15.1" +version = "2.16.0" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index dac5884..2328cf4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "navi" -version = "2.15.1" +version = "2.16.0" authors = ["Denis Isidoro "] edition = "2018" description = "An interactive cheatsheet tool for the command-line" diff --git a/alfred/alfred0.bash b/alfred/alfred0.bash deleted file mode 100755 index 7976690..0000000 --- a/alfred/alfred0.bash +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -source "${HOME}/.bashrc" -export PATH="/usr/local/bin:$PATH" - -if [ -n "${snippet:-}" ]; then - echo -n "$(navi alfred check)" -else - echo -n "__start" -fi diff --git a/alfred/alfred1.bash b/alfred/alfred1.bash deleted file mode 100755 index a1424a3..0000000 --- a/alfred/alfred1.bash +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -source "${HOME}/.bashrc" -export PATH="/usr/local/bin:$PATH" - -_hack() { - sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g' -} - -if [ -n "${snippet:-}" ]; then - navi alfred suggestions | _hack -else - navi alfred start | _hack -fi diff --git a/alfred/alfred2.bash b/alfred/alfred2.bash deleted file mode 100755 index d067437..0000000 --- a/alfred/alfred2.bash +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -source "${HOME}/.bashrc" -export PATH="/usr/local/bin:$PATH" - -if [ -n "${varname:-}" ]; then - echo -n "$(navi alfred transform)" | tr -d '\n' -else - echo -n "$snippet" -fi diff --git a/alfred/alfred3.bash b/alfred/alfred3.bash deleted file mode 100755 index e71f021..0000000 --- a/alfred/alfred3.bash +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -case "${snippet:-}" in - *docker*|*osascript*|*Finder*|*open*) exit 0 ;; -esac - -printf "terminal" diff --git a/alfred/icon.png b/alfred/icon.png deleted file mode 100644 index 99d15128eef76381c408538f3126037fa6c4f5b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*B0)E-)yf*tCwbI=PYir$b2k6d$3DTnQd8Q9iU=O$LFFhJf~D{kR_QAp#6hE4v5cI$!A zUtB)lBY9c)*S+lgI7PLC{o=i12PKcue3JRVr&3K8V+5>g5`UVes2%^z_H6m@ z8~Dq&CZo}Pa@1nZ+ycDRP@V(VN||cQF(-9gOzOIAT)Uo2d)INrl(*o>hurhI& z2yh|Y{Wm6B?mdN;Qd9{V(wiG-W(0(lZ0Sh-n}m?;*}mx%2*iDMLq!c$KuU!QlLrM2Dv z0pe!q}rT^CvgIz;Uu}DQ>vHs)-0U%&zhDA4=LjMDn!V-o6 diff --git a/alfred/info.plist b/alfred/info.plist deleted file mode 100644 index 6159f67..0000000 --- a/alfred/info.plist +++ /dev/null @@ -1,1039 +0,0 @@ - - - - - bundleid - com.github.denisidoro.navi - category - Tools - connections - - 083DDA39-DE4E-4EB4-9781-CDC89F766CBC - - - destinationuid - B3B967BC-EC30-47DE-B233-2F3F97568857 - modifiers - 0 - modifiersubtext - - vitoclose - - - - 2480F455-3F7F-4BE2-A268-698C5DB28761 - - - destinationuid - 3CE4BEC1-BEBE-4A11-B182-E63693AE2FE6 - modifiers - 0 - modifiersubtext - - vitoclose - - - - 282E2B68-29A1-4EF0-B328-2BE38CBF67F0 - - - destinationuid - ABA74294-992D-4528-A609-964B0ACA9346 - modifiers - 0 - modifiersubtext - - vitoclose - - - - 2B0EE026-57A9-4097-ACE7-FE4E78F20EC0 - - - destinationuid - EB668A02-2BBA-4539-B4C0-20F2498ECD71 - modifiers - 0 - modifiersubtext - - sourceoutputuid - 4F6E003F-FB02-4432-B025-249F22385B86 - vitoclose - - - - destinationuid - EB668A02-2BBA-4539-B4C0-20F2498ECD71 - modifiers - 0 - modifiersubtext - - sourceoutputuid - F78DD511-9EC2-4272-8946-C6E3E269DE2E - vitoclose - - - - destinationuid - 083DDA39-DE4E-4EB4-9781-CDC89F766CBC - modifiers - 0 - modifiersubtext - - vitoclose - - - - 3CE4BEC1-BEBE-4A11-B182-E63693AE2FE6 - - - destinationuid - 98658166-32FC-4F9D-8247-52BEDE6394EE - modifiers - 0 - modifiersubtext - - vitoclose - - - - destinationuid - BD60B64B-EC93-467E-AEC2-0489A3090113 - modifiers - 0 - modifiersubtext - - vitoclose - - - - 446FD3F8-2027-45CA-A156-A7F2C2B2C501 - - - destinationuid - C49EE1A3-92A1-4734-9B4F-E399299197AA - modifiers - 0 - modifiersubtext - - vitoclose - - - - 55C46852-4807-4374-95AB-CC055F4ECB7C - - - destinationuid - E8FC4B20-3DD5-4684-97C0-FBBC2FC1AD45 - modifiers - 0 - modifiersubtext - - vitoclose - - - - 7BBCBB25-8B82-40B8-BA37-B0C3894AFA98 - - - destinationuid - 282E2B68-29A1-4EF0-B328-2BE38CBF67F0 - modifiers - 0 - modifiersubtext - - vitoclose - - - - 7DD3BDE5-A157-42E5-9376-F681FB50A4EE - - - destinationuid - 3CE4BEC1-BEBE-4A11-B182-E63693AE2FE6 - modifiers - 0 - modifiersubtext - - vitoclose - - - - 98658166-32FC-4F9D-8247-52BEDE6394EE - - - destinationuid - B55D209F-7FF3-4C23-AA39-BA8E37B91452 - modifiers - 0 - modifiersubtext - - vitoclose - - - - ABA74294-992D-4528-A609-964B0ACA9346 - - - destinationuid - 5E378616-C00A-4608-9313-8D7DCF421BC5 - modifiers - 0 - modifiersubtext - - sourceoutputuid - F78DD511-9EC2-4272-8946-C6E3E269DE2E - vitoclose - - - - destinationuid - 529BC67C-C77D-41CA-B095-996CC1317556 - modifiers - 0 - modifiersubtext - - vitoclose - - - - B3B967BC-EC30-47DE-B233-2F3F97568857 - - - destinationuid - 2480F455-3F7F-4BE2-A268-698C5DB28761 - modifiers - 0 - modifiersubtext - - vitoclose - - - - B55D209F-7FF3-4C23-AA39-BA8E37B91452 - - - destinationuid - 93437EDA-0308-467D-BE3F-6855C638D49D - modifiers - 0 - modifiersubtext - - sourceoutputuid - F78DD511-9EC2-4272-8946-C6E3E269DE2E - vitoclose - - - - destinationuid - 446FD3F8-2027-45CA-A156-A7F2C2B2C501 - modifiers - 0 - modifiersubtext - - vitoclose - - - - C49EE1A3-92A1-4734-9B4F-E399299197AA - - - destinationuid - 7BBCBB25-8B82-40B8-BA37-B0C3894AFA98 - modifiers - 0 - modifiersubtext - - vitoclose - - - - E8FC4B20-3DD5-4684-97C0-FBBC2FC1AD45 - - - destinationuid - 2B0EE026-57A9-4097-ACE7-FE4E78F20EC0 - modifiers - 0 - modifiersubtext - - vitoclose - - - - EB668A02-2BBA-4539-B4C0-20F2498ECD71 - - - destinationuid - 7DD3BDE5-A157-42E5-9376-F681FB50A4EE - modifiers - 0 - modifiersubtext - - vitoclose - - - - F05BFEA8-AEE7-486A-9A54-B3162A233BAC - - - destinationuid - E8FC4B20-3DD5-4684-97C0-FBBC2FC1AD45 - modifiers - 0 - modifiersubtext - - vitoclose - - - - - createdby - Denis Isidoro - description - Integration with navi, the interactive cheatsheet tool for the command-line - disabled - - name - navi - objects - - - config - - externaltriggerid - play - passinputasargument - - passvariables - - workflowbundleid - self - - type - alfred.workflow.output.callexternaltrigger - uid - 93437EDA-0308-467D-BE3F-6855C638D49D - version - 1 - - - config - - alfredfiltersresults - - alfredfiltersresultsmatchmode - 2 - argumenttreatemptyqueryasnil - - argumenttrimmode - 0 - argumenttype - 1 - escaping - 102 - keyword - n - queuedelaycustom - 3 - queuedelayimmediatelyinitially - - queuedelaymode - 0 - queuemode - 1 - runningsubtext - Generating results... - script - #!/bin/bash -# -# Alfred Script Filter JSON format -# -# This example demonstrates all fields available for populating results. -# -# For an in-depth explanation, use the (?) help button to the bottom left. -# - -_print_snippets() { - - IFS=$'\n' - - items="{\"items\": [" - uid="$RANDOM" - - snippets="$(cat uber.cheat | grep '^#' | sed 's/^# //')" - - for line in $snippets; do - - # title="$(echo "$line" | tr -d '"')" - title="$(echo "$line" | tr -d '"')" - uid="$title" - - item=$(cat <<EOF -{ - "uid": "$uid", - "type": "file", - "title": "$title", - "subtitle": "subtitle", - "arg": "echo <foo> <bar>", - "autocomplete": "Desktop", - "icon": { - "type": "fileicon", - "path": "~/Desktop" - } -}, -EOF - ) - - items="$items $item" - - done - - echo "${items%?} ]}" - -} - -_interpolate() { - - snippet="$1" - - IFS=$'\n' - - items="{\"items\": [" - uid="$RANDOM" - - snippets="foo - bar" - - for line in $snippets; do - - # title="$(echo "$line" | tr -d '"')" - title="$(echo "$line" | tr -d '"')" - uid="$title" - - item=$(cat <<EOF -{ - "uid": "$uid", - "type": "file", - "title": "lorem", - "subtitle": "subtitle", - "arg": "ipsum", - "autocomplete": "Desktop", - "icon": { - "type": "fileicon", - "path": "~/Desktop" - } -}, -EOF - ) - - items="$items $item" - - done - - echo "${items%?} ]}" - -} - -if [ -n "${snippet:-} "]; then - _interpolate "$snippet" -elif [ -n "${query:-} "]; then - _interpolate "$query" -else - _print_snippets -fi - - scriptargtype - 1 - scriptfile - alfred1.bash - subtext - - title - navi - type - 8 - withspace - - - type - alfred.workflow.input.scriptfilter - uid - 7DD3BDE5-A157-42E5-9376-F681FB50A4EE - version - 3 - - - config - - argument - - variables - - - type - alfred.workflow.utility.argument - uid - EB668A02-2BBA-4539-B4C0-20F2498ECD71 - version - 1 - - - config - - concurrently - - escaping - 102 - script - echo asdsds - scriptargtype - 1 - scriptfile - alfred0.bash - type - 8 - - type - alfred.workflow.action.script - uid - E8FC4B20-3DD5-4684-97C0-FBBC2FC1AD45 - version - 2 - - - config - - triggerid - play - - type - alfred.workflow.trigger.external - uid - 55C46852-4807-4374-95AB-CC055F4ECB7C - version - 1 - - - config - - concurrently - - escaping - 102 - script - echo asdsds - scriptargtype - 1 - scriptfile - alfred2.bash - type - 8 - - type - alfred.workflow.action.script - uid - 3CE4BEC1-BEBE-4A11-B182-E63693AE2FE6 - version - 2 - - - config - - conditions - - - inputstring - {query} - matchcasesensitive - - matchmode - 0 - matchstring - __start - outputlabel - start - uid - F78DD511-9EC2-4272-8946-C6E3E269DE2E - - - inputstring - {query} - matchcasesensitive - - matchmode - 0 - matchstring - - outputlabel - suggestion - uid - 4F6E003F-FB02-4432-B025-249F22385B86 - - - elselabel - free input - - type - alfred.workflow.utility.conditional - uid - 2B0EE026-57A9-4097-ACE7-FE4E78F20EC0 - version - 1 - - - config - - conditions - - - inputstring - {var:snippet} - matchcasesensitive - - matchmode - 4 - matchstring - <[\w\d_\-]+> - outputlabel - variable left - uid - F78DD511-9EC2-4272-8946-C6E3E269DE2E - - - elselabel - no variables - - type - alfred.workflow.utility.conditional - uid - B55D209F-7FF3-4C23-AA39-BA8E37B91452 - version - 1 - - - config - - argument - - variables - - snippet - {query} - - - type - alfred.workflow.utility.argument - uid - 98658166-32FC-4F9D-8247-52BEDE6394EE - version - 1 - - - config - - escaping - 0 - script - {var:snippet} - - type - alfred.workflow.action.terminalcommand - uid - 5E378616-C00A-4608-9313-8D7DCF421BC5 - version - 1 - - - config - - concurrently - - escaping - 102 - script - echo asdsds - scriptargtype - 1 - scriptfile - alfred3.bash - type - 8 - - type - alfred.workflow.action.script - uid - 282E2B68-29A1-4EF0-B328-2BE38CBF67F0 - version - 2 - - - config - - conditions - - - inputstring - {query} - matchcasesensitive - - matchmode - 0 - matchstring - terminal - outputlabel - terminal - uid - F78DD511-9EC2-4272-8946-C6E3E269DE2E - - - elselabel - else - - type - alfred.workflow.utility.conditional - uid - ABA74294-992D-4528-A609-964B0ACA9346 - version - 1 - - - config - - matchmode - 0 - matchstring - - replacestring - " - - type - alfred.workflow.utility.replace - uid - C49EE1A3-92A1-4734-9B4F-E399299197AA - version - 2 - - - config - - argument - - variables - - snippet - {query} - - - type - alfred.workflow.utility.argument - uid - 7BBCBB25-8B82-40B8-BA37-B0C3894AFA98 - version - 1 - - - config - - argument - {var:snippet} - variables - - - type - alfred.workflow.utility.argument - uid - 446FD3F8-2027-45CA-A156-A7F2C2B2C501 - version - 1 - - - config - - action - 0 - argument - 0 - focusedappvariable - - focusedappvariablename - - hotkey - 51 - hotmod - 1966080 - hotstring - - leftcursor - - modsmode - 0 - relatedAppsMode - 0 - - type - alfred.workflow.trigger.hotkey - uid - F05BFEA8-AEE7-486A-9A54-B3162A233BAC - version - 2 - - - config - - argument - '{query}', {allvars} - cleardebuggertext - - processoutputs - - - type - alfred.workflow.utility.debug - uid - BD60B64B-EC93-467E-AEC2-0489A3090113 - version - 1 - - - config - - concurrently - - escaping - 0 - script - source "${HOME}/.bashrc" -export PATH="/usr/local/bin:$PATH" - -eval "$snippet" - scriptargtype - 0 - scriptfile - navi - type - 0 - - type - alfred.workflow.action.script - uid - 529BC67C-C77D-41CA-B095-996CC1317556 - version - 2 - - - config - - argumenttype - 1 - subtext - {var:snippet} - text - Input value for <{var:varname}> - withspace - - - type - alfred.workflow.input.keyword - uid - B3B967BC-EC30-47DE-B233-2F3F97568857 - version - 1 - - - config - - argument - - variables - - free - {query} - - - type - alfred.workflow.utility.argument - uid - 2480F455-3F7F-4BE2-A268-698C5DB28761 - version - 1 - - - config - - argument - - variables - - varname - {query} - - - type - alfred.workflow.utility.argument - uid - 083DDA39-DE4E-4EB4-9781-CDC89F766CBC - version - 1 - - - readme - - uidata - - 083DDA39-DE4E-4EB4-9781-CDC89F766CBC - - xpos - 520 - ypos - 380 - - 2480F455-3F7F-4BE2-A268-698C5DB28761 - - xpos - 750 - ypos - 375 - - 282E2B68-29A1-4EF0-B328-2BE38CBF67F0 - - xpos - 1445 - ypos - 255 - - 2B0EE026-57A9-4097-ACE7-FE4E78F20EC0 - - xpos - 370 - ypos - 170 - - 3CE4BEC1-BEBE-4A11-B182-E63693AE2FE6 - - xpos - 820 - ypos - 165 - - 446FD3F8-2027-45CA-A156-A7F2C2B2C501 - - xpos - 1225 - ypos - 285 - - 529BC67C-C77D-41CA-B095-996CC1317556 - - xpos - 1720 - ypos - 340 - - 55C46852-4807-4374-95AB-CC055F4ECB7C - - xpos - 10 - ypos - 165 - - 5E378616-C00A-4608-9313-8D7DCF421BC5 - - xpos - 1715 - ypos - 220 - - 7BBCBB25-8B82-40B8-BA37-B0C3894AFA98 - - xpos - 1370 - ypos - 285 - - 7DD3BDE5-A157-42E5-9376-F681FB50A4EE - - xpos - 605 - ypos - 80 - - 93437EDA-0308-467D-BE3F-6855C638D49D - - xpos - 1225 - ypos - 60 - - 98658166-32FC-4F9D-8247-52BEDE6394EE - - xpos - 985 - ypos - 195 - - ABA74294-992D-4528-A609-964B0ACA9346 - - xpos - 1590 - ypos - 275 - - B3B967BC-EC30-47DE-B233-2F3F97568857 - - xpos - 600 - ypos - 350 - - B55D209F-7FF3-4C23-AA39-BA8E37B91452 - - xpos - 1055 - ypos - 185 - - BD60B64B-EC93-467E-AEC2-0489A3090113 - - xpos - 1010 - ypos - 340 - - C49EE1A3-92A1-4734-9B4F-E399299197AA - - xpos - 1295 - ypos - 285 - - E8FC4B20-3DD5-4684-97C0-FBBC2FC1AD45 - - xpos - 210 - ypos - 165 - - EB668A02-2BBA-4539-B4C0-20F2498ECD71 - - xpos - 525 - ypos - 165 - - F05BFEA8-AEE7-486A-9A54-B3162A233BAC - - xpos - 10 - ypos - 310 - - - variablesdontexport - - version - 0.1.0 - webaddress - https://github.com/denisidoro - - diff --git a/docs/alfred.md b/docs/alfred.md index 2858021..0acc43d 100644 --- a/docs/alfred.md +++ b/docs/alfred.md @@ -5,9 +5,14 @@ This is *experimental*. If you face any issues, please report [here](https://git ![Alfred demo](https://user-images.githubusercontent.com/3226564/80294838-582b1b00-8743-11ea-9eb5-a335d8eed833.gif) +### Note + +Support for alfred has been been removed. The latest version which has some support for it is [2.15.1](https://github.com/denisidoro/navi/releases/tag/v2.15.1). + + ### Instructions - make sure you have [Alfred Powerpack](https://www.alfredapp.com/powerpack/) -- make sure **navi** is up to date +- make sure **navi** [2.15.1](https://github.com/denisidoro/navi/releases/tag/v2.15.1) is installed - make sure that the `navi` binary is in the `$PATH` determined by `~/.bashrc` -- download and install the `.alfredworkflow` for the [latest release](https://github.com/denisidoro/navi/releases/latest) +- download and install the [latest .alfredworkflow available](https://github.com/denisidoro/navi/releases/tag/v2.15.1) diff --git a/scripts/action b/scripts/action index 61fe162..89c3930 100755 --- a/scripts/action +++ b/scripts/action @@ -97,27 +97,10 @@ _ls() { ls -la "$@" || true } -workflow() { - - WORKFLOW_DIR="${NAVI_HOME}/target/workflow" - - cd "$NAVI_HOME" - - rm -rf "${NAVI_HOME}/target" 2> /dev/null || true - - mkdir -p "$WORKFLOW_DIR" 2> /dev/null || true - - cp ${NAVI_HOME}/alfred/* "$WORKFLOW_DIR" - cd "$WORKFLOW_DIR" - zip -j -r navi.zip * - -} - cmd="$1" shift case "$cmd" in "release") release "$@" ;; - "workflow") workflow "$@" ;; *) exit 2 ;; esac diff --git a/scripts/fix b/scripts/fix index e25c8ac..d5d4c1a 100755 --- a/scripts/fix +++ b/scripts/fix @@ -20,7 +20,5 @@ cargo clippy || true header "dot code beautify..." find scripts -type f | xargs -I% dot code beautify % || true -dot code beautify "${NAVI_HOME}/alfred/alfred.bash" || true -dot code beautify "${NAVI_HOME}/alfred/alfred2.bash" || true dot code beautify "${NAVI_HOME}/tests/core.bash" || true dot code beautify "${NAVI_HOME}/tests/run" || true diff --git a/src/cmds/alfred.rs b/src/cmds/alfred.rs deleted file mode 100644 index 426402e..0000000 --- a/src/cmds/alfred.rs +++ /dev/null @@ -1,115 +0,0 @@ -use crate::env_var; -use crate::filesystem; -use crate::shell::BashSpawnError; -use crate::structures::cheat::Suggestion; -use crate::structures::config::Config; -use crate::structures::fetcher::Fetcher; -use crate::writer; -use anyhow::Context; -use anyhow::Error; -use std::process::{Command, Stdio}; - -pub fn main(config: Config) -> Result<(), Error> { - let mut child = Command::new("cat") - .stdin(Stdio::piped()) - .spawn() - .context("Unable to create child")?; - let stdin = child.stdin.as_mut().context("Unable to get stdin")?; - let mut writer = writer::alfred::Writer::new(); - - writer::alfred::print_items_start(None); - - let fetcher = filesystem::Fetcher::new(config.path, None); - fetcher - .fetch(stdin, &mut writer, &mut Vec::new()) - .context("Failed to parse variables intended for finder")?; - - // make sure everything was printed to stdout before attempting to close the items vector - let _ = child.wait_with_output().context("Failed to wait for fzf")?; - - writer::alfred::print_items_end(); - Ok(()) -} - -fn prompt_finder(suggestion: &Suggestion) -> Result { - let (suggestion_command, _suggestion_opts) = suggestion; - - let child = Command::new("bash") - .stdout(Stdio::piped()) - .arg("-c") - .arg(&suggestion_command) - .spawn() - .map_err(|e| BashSpawnError::new(suggestion_command, e))?; - - let suggestions = String::from_utf8( - child - .wait_with_output() - .context("Failed to wait and collect output from bash")? - .stdout, - ) - .context("Suggestions are invalid utf8")?; - - Ok(suggestions) -} - -pub fn suggestions(config: Config, dry_run: bool) -> Result<(), Error> { - let mut child = Command::new("cat") - .stdin(Stdio::piped()) - .stdout(Stdio::null()) - .spawn() - .context("Unable to create child")?; - let stdin = child.stdin.as_mut().context("Unable to get stdin")?; - let mut writer = writer::alfred::Writer::new(); - - let fetcher = filesystem::Fetcher::new(config.path, None); - let variables = fetcher - .fetch(stdin, &mut writer, &mut Vec::new()) - .context("Failed to parse variables intended for finder")? - .expect("Empty variable map"); - - let tags = env_var::get("tags").context(r#"The env var "tags" isn't set"#)?; - let snippet = env_var::get("snippet").context(r#"The env var "snippet" isn't set"#)?; - - let capture = writer::VAR_REGEX.captures_iter(&snippet).next(); - let bracketed_varname = &(capture.expect("Invalid capture"))[0]; - let varname = &bracketed_varname[1..bracketed_varname.len() - 1]; - let command = variables.get_suggestion(&tags, &varname); - - if dry_run { - if command.is_none() { - println!("{}", varname); - } - return Ok(()); - } - - writer::alfred::print_items_start(Some(varname)); - - let command = command.context("Invalid command")?; - let lines = prompt_finder(command).context("Invalid lines")?; - - writer.reset(); - - for line in lines.split('\n') { - writer.write_suggestion(&snippet, &varname, &line); - } - - writer::alfred::print_items_end(); - - Ok(()) -} - -pub fn transform() -> Result<(), Error> { - let snippet = env_var::get("snippet").context(r#"The env var "snippet" isn't set"#)?; - let varname = env_var::get("varname").context(r#"The env var "varname" isn't set"#)?; - let value = if let Ok(v) = env_var::get(&varname) { - v - } else { - env_var::get("free").context("The env var for varname isn't set")? - }; - - let bracketed_varname = format!("<{}>", varname); - let interpolated_snippet = snippet.replace(&bracketed_varname, &value); - println!("{}", interpolated_snippet); - - Ok(()) -} diff --git a/src/cmds/mod.rs b/src/cmds/mod.rs index de7fdf5..229a5ee 100644 --- a/src/cmds/mod.rs +++ b/src/cmds/mod.rs @@ -1,4 +1,3 @@ -pub mod alfred; pub mod core; pub mod func; pub mod info; diff --git a/src/handler.rs b/src/handler.rs index 241ad64..447235e 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -1,6 +1,6 @@ use crate::cmds; -use crate::structures::config::Command::{Alfred, Fn, Info, Preview, PreviewVar, Repo, Widget}; -use crate::structures::config::{AlfredCommand, Config, RepoCommand}; +use crate::structures::config::Command::{Fn, Info, Preview, PreviewVar, Repo, Widget}; +use crate::structures::config::{Config, RepoCommand}; use anyhow::Context; use anyhow::Error; @@ -38,20 +38,6 @@ pub fn handle_config(config: Config) -> Result<(), Error> { } }, - Alfred { cmd } => match cmd { - AlfredCommand::Start => { - cmds::alfred::main(config).context("Failed to call Alfred starting function") - } - AlfredCommand::Suggestions => cmds::alfred::suggestions(config, false) - .context("Failed to call Alfred suggestion function"), - AlfredCommand::Check => { - cmds::alfred::suggestions(config, true).context("Failed to call Alfred check function") - } - AlfredCommand::Transform => { - cmds::alfred::transform().context("Failed to call Alfred transform function") - } - }, - _ => cmds::core::main(config), }, } diff --git a/src/structures/config.rs b/src/structures/config.rs index 052a13a..55203b8 100644 --- a/src/structures/config.rs +++ b/src/structures/config.rs @@ -194,12 +194,6 @@ pub enum Command { #[clap(possible_values = INFO_POSSIBLE_VALUES, case_insensitive = true)] info: Info, }, - /// Helper command for Alfred integration - #[clap(setting = AppSettings::Hidden)] - Alfred { - #[clap(subcommand)] - cmd: AlfredCommand, - }, } #[derive(Debug, Clap)] @@ -213,18 +207,6 @@ pub enum RepoCommand { Browse, } -#[derive(Debug, Clap)] -pub enum AlfredCommand { - /// Outputs a JSON with commands - Start, - /// Outputs a JSON with variable suggestions - Suggestions, - /// Transforms the snippet env var with the selected value - Transform, - /// Checks whether to use free input - Check, -} - pub enum Source { Filesystem(Option, Option), Tldr(String), diff --git a/src/writer/alfred.rs b/src/writer/alfred.rs deleted file mode 100644 index b0085ba..0000000 --- a/src/writer/alfred.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::structures::item::Item; -use crate::writer; - -pub struct Writer { - is_first: bool, -} - -fn escape_for_json(txt: &str) -> String { - txt.replace('\\', "\\\\") - .replace('"', "“") - .replace(writer::NEWLINE_ESCAPE_CHAR, " ") -} - -pub fn print_items_start(varname: Option<&str>) { - print!("{{"); - - if let Some(v) = varname { - print!(r#""variables": {{"varname": "{varname}"}},"#, varname = v); - } - - println!(r#""items": ["#); -} - -pub fn print_items_end() { - println!(r#"]}}"#); -} - -impl writer::Writer for Writer { - fn write(&mut self, item: &Item) -> String { - let prefix = if self.is_first { - self.is_first = false; - "" - } else { - "," - }; - - let tags = escape_for_json(&item.tags); - let comment = escape_for_json(&item.comment); - let snippet = escape_for_json(&item.snippet); - - format!( - r#"{prefix}{{"type":"file","title":"{comment}","match":"{comment} {tags} {snippet}","subtitle":"{tags} :: {snippet}","variables":{{"tags":"{tags}","comment":"{comment}","snippet":"{snippet}"}},"icon":{{"path":"icon.png"}}}}"#, - prefix = prefix, - tags = tags, - comment = comment, - snippet = snippet - ) - } -} - -impl Writer { - pub fn new() -> Writer { - Writer { is_first: true } - } - - pub fn reset(&mut self) { - self.is_first = true - } - - pub fn write_suggestion(&mut self, snippet: &str, varname: &str, line: &str) { - if line.len() < 3 { - return; - } - - let prefix = if self.is_first { - self.is_first = false; - "" - } else { - "," - }; - - println!( - r#"{prefix}{{"title":"{value}","subtitle":"{snippet}","variables":{{"{varname}":"{value}"}},"icon":{{"path":"icon.png"}}}}"#, - prefix = prefix, - snippet = snippet, - varname = varname, - value = line - ); - } -} diff --git a/src/writer/mod.rs b/src/writer/mod.rs index 62e40b8..d3022a5 100644 --- a/src/writer/mod.rs +++ b/src/writer/mod.rs @@ -1,4 +1,3 @@ -pub mod alfred; pub mod terminal; use crate::structures::item::Item;