diff --git a/README-snap.md b/README-snap.md new file mode 100644 index 00000000..6ef768fb --- /dev/null +++ b/README-snap.md @@ -0,0 +1,75 @@ +# How to use `jc` with `snap` + +## How to build `snap` package + +- Install `snapd`. [One](https://snapcraft.io/docs/installing-snapd) or [two](https://github.com/don-rumata/ansible-role-install-snap). + +- Install `snapcraft`: + +```bash +$ sudo snap install snapcraft --classic +``` + +- Update snapd: + +```bash +$ sudo snap refresh snapcraft --edge +``` + +- Clone the repo: + +```bash +$ git clone https://github.com/kellyjonbrazil/jc +``` + +- Change the directory: + +```bash +$ cd ./jc +``` + +- Select branch: + +```bash +$ git checkout snap-support +``` + +- Initialize LXD: + +```bash +$ lxd init --auto +``` + +- Build `.snap` file: + +```bash +$ snapcraft +``` + +## How to install local snap file + +```bash +$ snap install --dangerous ./jc_*_amd64.snap +``` + +## How to use `jc` with plugins + +- Put your plugin in the `"$HOME/.local/share/jc"` directory. + +- To connect the directory, run: + +```bash +snap connect jc:dot-jc-plugins snapd +``` + +## Urls + +- + +- + +- + +- + +- diff --git a/snap/local/jc-launcher.sh b/snap/local/jc-launcher.sh new file mode 100755 index 00000000..fae42736 --- /dev/null +++ b/snap/local/jc-launcher.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +PATH_TO_JC="$SNAP/bin/jc" + +# Don't work. I don't know why. +# if [ -w "$SNAP_REAL_HOME/.local/share/jc" ] ; then + +if ls "$SNAP_REAL_HOME/.local/share/jc" 1>/dev/null 2>/dev/null +then + HOME="$SNAP_REAL_HOME" "$PATH_TO_JC" "$@"; +else + "$PATH_TO_JC" "$@"; +fi diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000..44774c08 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,58 @@ +--- +name: jc +title: Convert command output to json +summary: CLI tool that converts the output command-line tools to JSON +description: | + CLI tool and python library that converts the output of popular command-line + tools, file-types, and common strings to JSON, YAML, or Dictionaries. + This allows piping of output to tools like jq and simplifying automation scripts. + + How to use `jc` with plugins: + 1. Put your plugin in the "$HOME/.local/share/jc" directory. + 2. Run for `snap connect jc:dot-jc-plugins snapd` connect the directory. +# version: git +base: core22 +confinement: strict +license: MIT +type: app + +website: https://github.com/kellyjonbrazil/jc +contact: Kelly Brazil +source-code: https://github.com/kellyjonbrazil/jc +issues: https://github.com/kellyjonbrazil/jc/issues + +adopt-info: jc + +parts: + launcher: + plugin: dump + source: snap/local + organize: + jc-launcher.sh: bin/ + + jc: + plugin: python + source: . + # pulled v1.17.2, `git describe` + # source: https://github.com/kellyjonbrazil/jc + override-pull: | + craftctl default + JC_VERSION=$(grep version= setup.py | cut -d '=' -f 2 | sed "s/,$// ; s/'//g") + craftctl set version=$JC_VERSION + craftctl set grade="stable" + +plugs: + dot-jc-plugins: + interface: personal-files + read: + - $HOME/.local + - $HOME/.local/share + +apps: + jc: + command: bin/jc-launcher.sh + environment: + LC_ALL: C.UTF-8 + plugs: + - home + - dot-jc-plugins