Skip to content

Home for Collateral Engineering Services utility shell scripts.

License

Notifications You must be signed in to change notification settings

dewiz-xyz/shell-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CES Shell Utils

Home for Collateral Engineering Services utility shell scripts.

Installation

As Dependency

The easiest way is to add this repo as a dependency to your own repo:

git submodule add https://github.com/clio-finance/shell-utils ./lib/shell-utils

Then you can reference all utilities through the ./lib/shell-utils/bin/ directory:

./lib/shell-utils/bin/json-to-env

From Released Packages

Go to releases and download the latest ces-shell-utils-x.y.z.tar.gz file.

Un-tar the release file with:

tar -xzf ces-shell-utils-x.y.z.tar.gz

Run the install.sh script:

cd ces-shell-utils-x.y.z
./install.sh

If you want to change the installation location, use the $PREFIX env var:

PREFIX=path/to/installation ./install.sh

To uninstall, run the uninstall.sh script:

cd ces-shell-utils-x.y.z
./uninstall.sh

From Source

See the required dependencies.

Clone this repo and then run:

make
make install

Commands and documentation will be placed into $HOME/.local by default.

Make sure you have $HOME/.local/bin in your $PATH.

If you want to change the installation location, use the $PREFIX env var:

make
PREFIX=path/to/installation make install

To uninstall, run:

make uninstall
# If you changed $PREFIX during installation you will have to do the same here:
# PREFIX=path/to/installation make uninstall

Commands

json-to-env

Requirements

Usage

JSON‐TO‐ENV(1)                             User          Commands
JSON‐TO‐ENV(1)

NAME
       json‐to‐env ‐ manual page for json‐to‐env 0.1.0

SYNOPSIS
       json‐to‐env [‐hvx] [‐f] <file>
       json‐to‐env [‐hvx] [‐f] ‐
       json‐to‐env [‐hvx]

DESCRIPTION
       json‐to‐env  ‐  Converts a JSON file into POSIX shell  en‐
vironment vari‐
       able  declarations  Each  ‘key‘:  ‘value‘   pair  will  be
converted  to  a
       ‘key=value‘  statement.   If  <file> is not provided or is
‘‐‘, it will
       read from stdin.

OPTIONS
       ‐f, ‐‐file
              The path to the file to read from.

       ‐h, ‐‐help
              Show this help text.

       ‐v, ‐‐version
              Show the version.

       ‐x, ‐‐export
              Prepend ’export’ to the generated environment vari‐
ables.

EXAMPLES
       json‐to‐env /path/to/file.json
              Regular usage

       cat /path/to/file.json | json‐to‐env
              Same as above

       json‐to‐env ‐x /path/to/file.jsoni
              Export the variables (‘export VAR=VALUE‘)

       json‐to‐env ‐f /path/to/file.json
              Can use the ‐f option

       json‐to‐env /path/to/file.jsoni
              Or simply a positional argument

       json‐to‐env <<< "{"VAR":"VALUE"}"
              JSON literal

json‐to‐env        0.2.0                        March        2022
JSON‐TO‐ENV(1)

changelog-to-json

Requirements

Usage

CHANGELOG‐TO‐JSON(1)                       User          Commands
CHANGELOG‐TO‐JSON(1)

NAME
       changelog‐to‐json  ‐  manual  page  for  changelog‐to‐json
0.2.0

SYNOPSIS
       changelog‐to‐json [<changelog_address>]
       changelog‐to‐json [‐hv]

DESCRIPTION
       changelog‐to‐json  ‐  Fetches  the  info from the on‐chain
changelog at
       <changelog_address> and extract it into a JSON  file.   If
<changelog_ad‐
       dress>  is  not  provided,  it  will  attempt to read from
stdin.

OPTIONS
       ‐h, ‐‐help
              Show this help text.

       ‐v, ‐‐version Show the version.

EXAMPLES
       changelog‐to‐json \
         0x7EafEEa64bF6F79A79853F4A660e0960c821BA50
              Fetches the info from CES Goerli MCD

       jq ‐r ’.CHANGELOG’ ’addresses.json’ | changelog‐to‐json
              When the address is extracted  from  another  file,
it  can  be passed in as input

       changelog‐to‐json $(jq ‐r ’.CHANGELOG’ ’addresses.json’)
              This is equivalent to the command above

changelog‐to‐json        0.2.0                  March        2022
CHANGELOG‐TO‐JSON(1)

Contributing

How To

Add a New Utility

Add a new file in the ./bin/ directory. The file should have no extension and it should be self-executable (i.e.: #!/bin/bash for bash scripts, #!/bin/env python for python scripts, #!/bin/env node for node.js scripts).

Make sure the utility is properly documented and accepts at least the -h/--help and -v/--version options. See existing files for examples.

Make a Release

NOTICE: To be able to run the commands below you are required to have github-cli installed and properly configured.

This repo uses semver. To make a new release, update the $VERSION variable in Makefile to a proper value. After that, run in sequence:

make
make tag
make release

At this point, github-cli will prompt you about some details to document the release. Go to releases for some inspiration.

Requirements

  • make: build tool.
  • sed: a steam editor.
  • help2man: generates man files from the --help text of commands.
  • nroff: typesetting system that reads plain text mixed with formatting commands and produces formatted output.

Code Conduct

TODO.