Skip to main content

An HCLI connector that can be used to expose any CLI expressed through hypertext command line interface (HCLI) semantics.

Project description

An HCLI Connector that can be used to expose a REST API with a built-in CLI, via hypertext command line interface (HCLI) semantics.


HCLI Core implements an HCLI Connector, a type of Service Connector, as a WSGI application and provides a way for developers to expose a service hosted CLI, as a REST API, via HCLI semantics. Such an API exposes a “built-in” CLI that can be interacted with dynamically with any HCLI client. Up to date, in-band, man page style API/CLI documentation is readily available for use to help understand how to interact with the API.

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

You can find out more about HCLI on hcli.io [2]

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

Help shape HCLI and it’s ecosystem by raising issues on github!

[1] https://github.com/cometaj2/huckle

[2] http://hcli.io

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

[4] http://alps.io

Installation

hcli_core requires a supported version of Python and pip.

You’ll need an WSGI compliant application server to run hcli_core. For example, you can use Green Unicorn (https://gunicorn.org/)

pip install gunicorn

Install hcli_core via pip. You can launch gunicorn from anywhere by using “hcli_core path”. You can also look at the hcli_core help file.

You can curl your new service to understand what is being exposed. The HCLI root URL, to use with an HCLI client, is the cli link relation.

Install an HCLI client, for example Huckle (https://github.com/cometaj2/huckle), and access the sample CLI (e.g. jsonf or hg) exposed by HCLI Core. You may need to restart your terminal to be able to use the sample CLI by name directly (e.g. jsonf or hg); otherwise you can attempt to source ~/.bash_profile or ~/.bashrc).

Note that no CLI is actually installed by huckle. Huckle reads the HCLI semantics dynamically and ends up behaving like the CLI it targets:

pip install hcli_core

hcli_core help

gunicorn --workers=5 --threads=2 -b 127.0.0.1:8000 --chdir `hcli_core path` "hcli_core:connector()"

curl http://127.0.0.1:8000

pip install huckle

huckle help

huckle cli install http://127.0.0.1:8000

jsonf help

If you want to load a sample HCLI other than the default sample application, you can try loading the sample hg HCLI (hypertext GPT-3.5 chatbot). A folder path to any other 3rd party HCLI can be provided in the same way:

gunicorn --workers=5 --threads=2 --chdir `hcli_core path` "hcli_core:connector(\"`hcli_core sample hg`\")"

huckle cli install http://127.0.0.1:8000

hg help

Bugs

  • No good handling of control over request and response in cli code which can lead to exceptions and empty response client side.

  • The hfm sample HCLI fails disgracefully when copying a remote file name that doesn’t exist (server error).

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

hcli_core-0.11.7.tar.gz (51.5 kB view details)

Uploaded Source

Built Distribution

hcli_core-0.11.7-py2.py3-none-any.whl (69.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file hcli_core-0.11.7.tar.gz.

File metadata

  • Download URL: hcli_core-0.11.7.tar.gz
  • Upload date:
  • Size: 51.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for hcli_core-0.11.7.tar.gz
Algorithm Hash digest
SHA256 0b800458e956c2520544696aa71a76512c40bee1b6a40a6219f7150bcc921d2c
MD5 2315208c7c16b822511315a00550d36d
BLAKE2b-256 1c90235429ac01113a1ebeadcae4f5e240e6c660853b5f05c5000eb2fa999a35

See more details on using hashes here.

File details

Details for the file hcli_core-0.11.7-py2.py3-none-any.whl.

File metadata

  • Download URL: hcli_core-0.11.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 69.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for hcli_core-0.11.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dd2e21c577ff1c8b47624545962a0f8f081229bd5e0761629dd867ad5a14f147
MD5 d942e0407f4dd0235f758bc2ee84fd61
BLAKE2b-256 658004b466c5d224a63695c4e6038e96dab126c062384a89d1e5c2bab2db0823

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