npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aclii

v0.0.11

Published

Abstract Command Line Interface Interface

Downloads

5

Readme

aclii

Another Command Line Interface Interface

Synopsis

Write your CLI design in aclii.yml

name: my-command
commands:
  - name: list
    script: |
      ls -la

Build and use it

$ aclii put launcher /usr/local/bin/my-command
$ aclii put completion ~/.bashrc.d/my-command-completion
$ my-command list

Description

aclii is a command line parser generator

The core function of aclii is a command line parser generator for bash scripts. It can build a pure bash based command line options parser from descriptive YAML file, supports modern sub-command tree based command line definition.

Also aclii can build stand alone completion script for bash (and zsh). You can use aclii just for completion generator ( This is what originally I want to build ;-) )

aclii is not only a parser, but also argument handling launcher

aclii also can render a command line launcher script for any command line tools. This launcher can parse and validate args and show helps behalf of your proglam. You can get rid of those chores from your program, and just get a correct args as is, or as JSON compiled version of args.

aclii is not only a launcher, but powerful cli tool kit

You can use aclii launcher not only for programs you written, but also for any cli tools you use. You can write personal chores, or team-wide chores into YAML file and find them from command tree with auto completion support.

Please note that aclii is still very alpha version

Install

Install aclii

$ npm i -g aclii

Install completion file

aclii aclii-completion > {{ your completion dir }}/aclii_completion

Or for ephemeral testing

source <(aclii aclii-completion)

Or (above line works on ubuntu but not doen't on macos...)

$ tmp=$(mktemp) && aclii aclii-completion > $tmp && source $tmp && rm $tmp 

Ok , now aclii has been set up!

How to use

Go some new directory and put this config as aclii.yml

name: mytool
description: my tool for cli
helpstop: true
commands:
  - name: list-home
    description: show my home directory
    script: cd ~ && ls -la
    env: bash

now aclii can compile this to launcher by aclii render completion, and aclii render completion for bash_completion. Install them and try it!

$ aclii render launcher > /usr/local/bin/mytool && chmod +x /usr/local/bin/mytool
$ tmp=$(mktemp) && aclii render completion > $tmp && source $tmp && rm $tmp
$ mytool<TAB>

Use cases

For option parser of bash script

Write a command line definition into yaml file

# myscript.aclii.yml
name: myscript
options:
  - name: name
    type: string

Then compile the parser

aclii --file myscript.aclii.yml render parser > parser.sh

So in your script

#!/bin/bash
# $0 = myscript.sh
source $(dirname $0)/parser.sh "$@" # parse imports a function called `_q`
echo "name: $(_q 'name')"

This script prints "name: aclii" for the input ./myscript.sh --name aclii

For quick tool writing

If you're about to start writing some cli tool (in JavaScript? ruby? whatever) but if you're not familiar with that language and/or command option parser, aclii can help you. aclii launcher can parse options instead and launch your tool with options translated into JSON. You just have to JSON.parse() and then write the essential tasks. aclii can invoke your executable, or execute inline script.

This is an example of how aclii handle command line arguments. For command hello --language English hey paul thank you very much...

name: hello
description: Say hello
env: node
argstyle: json
commands:
  - name: hey
    wants:
      - name: name
        type: string
      - name: words
        type: string
        many: true
options:
  - name: language
    description: Select language
    type: string
script: |
  const args = JSON.parse(
    Buffer.from(process.argv[2], 'base64').toString() )
  console.dir(args)
  // this prints below...
  // {
  //   command: 'hello.hey',
  //   bin: 'hello',
  //   binpath: '',
  //   options: {
  //     language: 'English',
  //     name: 'paul',
  //     words: [ 'thank', 'you', 'very', 'much' ]
  //   }
  // }

Also, aclii launcher can show help pages which automatically generated from YAML file.

For team collaboration

If you're working for monorepo which maintained by multiple teams. For example backend and frontend team. There are many cool tools in both area but they don't know each others' stuff. Since frontend team don't know how to do perldoc and backend team don't know how npx is powerful. aclii can solve this situation by just writing a YAML config. Let's put a master launcher generated by aclii and navigate them with powerful auto-completion. If a command repo test frontend<TAB> show doable actions, repo build backend --help shows documents for them, and of course they are executable from single command. It could be helpful, isn't it?

For personal use

I know you have aliases which you wrote into ~/.*shrc but never invoked, and completely forgot how to use them. How many dead aliases do you have? aclii launcher can manage those items in single yaml file, with documentation and auto-completion, by just putting personal launcher, since you can write oneliners and scripts in aclii.yml and aclii can run them, like GH actions.

Example for personal use, with self update

name: ii
description: Personal tools launcher. To update, edit ~/.aclii/aclii.yml.
helpstop: true
commands:
  - name: maintain
    description: maintain this tool itself
    helpstop: true
    commands:
      - name: update
        description: Re-compile ii
        env: bash
        script: |
          cd ~/.aclii
          aclii render launcher > ~/.bin/ii
          aclii render completion > ~/.bashrc.d/ii
  - name: hey
    description: |
      notify me with desktop notification and voice
    script: |
      osascript -e 'display notification "へい"'
      say "へい"

Documentations

Limitations / Missing features / ToDos

  • Documentation
    • :white_check_mark: How to use aclii cli
    • :white_check_mark: how to write yaml file
  • :white_check_mark: Runtime Dependency to jq, it should be removed if possible
  • Completion file auto installer
  • :white_check_mark: Only bash is suppported / Need to support other environment
  • Bootstrap / Scatfold to create new aclii project
  • Help format
  • :white_check_mark: Auto completion format
  • short option support

Future Features

  • Dash off script bootstrap / implant aclii config into script file
  • Branch grafting for multiple aclii configs
  • Plaggable language support for inline scripting / scatfolding