Skip to main content

A CLI that can act as an impostor for any CLI expressed through hypertext command line interface (HCLI) semantics.

Project description

Huckle is a CLI that can act as an impostor for any CLI expressed via hypertext command line interface (HCLI) semantics.


Huckle provides a way for developers to interact with, or script around, any API that exposes HCLI semantics, while providing dynamic and up to date in-band access to all the API/CLI documentation, man page style, which showcases commands, options, and parameters available for execution.

Most, if not all, programming languages have a way to issue shell commands. With the help of a generic HCLI client such as Huckle, APIs that make use of HCLI semantics are readily consumable anywhere via the familiar CLI mode of operation, and this, without there being a need to write a custom and dedicated CLI to interact with a specific API.

You can access a simple example HCLI service to play with huckle on http://hcli.io [1]

The HCLI Internet-Draft [2] is a work in progress by the author and the current implementation leverages hal+json alongside a static form of ALPS (semantic profile) [3] to help enable widespread cross media-type support.

Help shape huckle and HCLI on the discussion list [4] or by raising issues on github!

[1] http://hcli.io

[2] https://github.com/cometaj2/I-D/tree/master/hcli

[3] http://alps.io

[4] https://groups.google.com/forum/#!forum/huck-hypermedia-unified-cli-with-a-kick

Install Python, pip and huckle

Huckle requires bash with access to man pages, Python and pip. Install a supported version of Python for your system.

Install huckle via Python’s pip:

pip install huckle

Basic usage

huckle env

This provides a sample environment configuration for your PATH environment variable. This can be permanently configured for your environment by adding the command ‘eval $(huckle env) in your shell startup configuration (e.g. .bashrc, .bash_profile, .profile)

huckle cli install <url>

This attempts to auto create and configure a CLI name if provided with the root URL of an HCLI API. If successful, the CLI can be invoked by name, after updating the path (see ‘huckle env’). You can permanently enable HCLI entrypoint scripts by adding ‘eval $(huckle env) to your a ~/.bashrc, ~/.bash_profile, or ~/.profile.

Note that an existing configuration file is left alone if the command is run multiple times for the same CLI.

An example HCLI that can be used with Huckle is available on hcli.io:

Alternatively, a WSGI application can be stood up very quickly using sample HCLIs available via hcli_core https://pypi.org/project/hcli-core/

huckle cli run <cliname>

This invokes the cliname to issue HCLI API calls; the details of which are left to API implementers.

Commands, options and parameters are presented gradually, to provide users with a way to incrementally discover and learn how the CLI is used.

<cliname> …

For brevity, the CLI name can and should be invoked directly rather than through “huckle cli run <cliname>.

<cliname> … help

The reserved “help” command can be used anywhere in a command line sequence to have huckle generate a man page from the last successfully received HCLI Document. This helps with CLI exploration.

huckle help

This opens up a man page that describes how to use huckle.

Configuration

Huckle uses small scripts under ~/.huckle/bin to enable CLIs to be invoked by name.

Huckle also uses CLI configuration files (e.g. ~/.huckle/etc/<cliname>/config) to associate a specific CLI to an HCLI API root URL and other CLI specific configuration.

Versioning

This project makes use of semantic versioning (http://semver.org) and may make use of the “devx”, “prealphax”, “alphax” “betax”, and “rcx” extensions where x is a number (e.g. 0.3.0-prealpha1) on github. Only full major.minor.patch releases will be pushed to pip from now on.

Supports

  • Supports HTTP/HTTPS

  • HCLI version 1.0 semantics for:

    • hal+json

  • Automatic man page generation with the “help” command, anywhere in a CLI.

  • Command line execution responses for

    • All media types

  • Streaming:

    • Handles very large stdin/stdout streams (fixed chunk size of 16834)

  • SOCKS tunneling through environment variables (ALL_PROXY)

  • Auto configuration of a CLI when provided with an HCLI API root URL (e.g. huckle cli install http://hcli.io/hcli/cli/jsonf?command=jsonf

  • Support listing of installed CLIs

  • Supports listing of the configuration of a CLI

  • Support auto discovery of cli link relations when attempting to install from a root resource that isn’t an hcli-document.

To Do

  • Fork restnavigator repo or otherwise adjust to use restnavigator with requests (single http client instead of two)

  • Support help docs output in the absence of man pages (e.g. git-bash on Windows)

  • Support HCLI version 1.0 semantics for:

    • Collection+JSON

    • hal+xml

    • Uber

    • HTML

    • Siren

    • JSON-LD

    • JSON API

    • Mason

  • Support stream configuration

    • sending and receiving streams (configurable via CLI config)

    • sending and receiving non-streams (configuration via CLI config)

    • chunk size for streams send/receive (configurable via CLI config)

  • Support non-stream send/receive (via CLI configuration)

  • Support various authentication and/or passthrough per CLI configuration

    • HTTP Basic Auth

    • HTTP Digest

    • Oauth2

    • X509 (HTTPS mutual authentication)

    • AWS

    • SAML

  • Better implementation for huckle params/options handling

  • Support for re-aliasing a CLI with additional huckle options (e.g. adding “–ssl-no-verify” to huckle cli jsonf’s shell script)

  • Support server certificate validation bypass (e.g. –ssl-no-verify. This is not secure but is sometimes useful to troubleshoot)

  • Support for viewing information about an HCLI root (e.g. huckle view http://hcli.io/hcli/cli/jsonf?command=jsonf

  • Support forward proxy configuration through proxy environment variables (HTTP_PROXY, HTTPS_PROXY)

  • Support hcli name conflic resolution (use namespaces?)

    • View currently selected namespace (e.g. huckle ns)

    • Viewing namespace list (e.g. huckle ns list)

    • Selecting a namespace (e.g. huckle ns use abc)

    • Remove an entire namespace and all associated CLIs (e.g. huckle ns rm abc)

    • Support adding and removing CLIs to namespaces

  • Support multipart/form-data for very large uploads (see requests-toolbelt)

  • Support HCLI nativization

  • Support for Huckle DEBUG mode

Bugs

  • There’s an edge case that’s not covered; when executing a cli by invoking the root of the HCLI only. And more specifically when the root is not valid HCLI when initially fetching the HALNavigator.

  • Disgraceful handling when a cli is invoked when the associated HCLI service is down

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

huckle-3.0.2.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

huckle-3.0.2-py2.py3-none-any.whl (13.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file huckle-3.0.2.tar.gz.

File metadata

  • Download URL: huckle-3.0.2.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for huckle-3.0.2.tar.gz
Algorithm Hash digest
SHA256 92b200dfd8e7cd26ddfce537e57b3d43833b0a3797fb7db9546ec9c48b129b6c
MD5 92238b6afde045ac411643e21f2c43f8
BLAKE2b-256 3785aa793faef88c0d37ab6eaedac603781899640329a8d27da0293e75e17124

See more details on using hashes here.

File details

Details for the file huckle-3.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: huckle-3.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for huckle-3.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d39ed7f81fb062894ca77a1deb0e6a2cf2a4bc001ee27b89a28fc4227353e715
MD5 c4eb97b9bc12b6352aab32726389b553
BLAKE2b-256 2fad3ca91bf2bc448673a7bd1312ecbb3cd3845144ec5d238354463e23933860

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page