sorashell

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 16 Imported by: 0

README

sorashell

Interactive shell for soracom-cli. Features include:

  • commands and flags automatic, interactive, fuzzy-match completion
  • just works by copying the cross-compiled binary file into the target environment. There is no need to build an environment or solve dependencies.

Install

$ go get github.com/rakyll/statik # install rakyll/statik, asset embedder
$ make sorashell
$ cp ./sorashell /path/to/your/bin/directory

Usage

  1. Install and configure soracom-cli according to the repo's README or SORACOM CLI 利用ガイド | SORACOM Developers (Japanese)
  2. Run sorashell
  3. The shell automatically provides suggestions as you type. Enjoy!
    • Tab to move cursor or display suggestions
    • Space to select
Tips and Tricks

You can:

  • fuzzy match commands, options, IMSIs, device IDs, etc. Try with subscribers get --imsi and type SIM status (online or offline), or a part of it's name.
  • use pipe (|) or redirect (>) with your risk e.g.
    SORASHELL> subscribers list --speed-class-filter s1.slow | jq '.[] | .imsi' > slow-subscribers.txt 
    
  • run local shell command by preceding the command with ! e.g.
    SORASHELL> !cd /Users/soracom/Desktop
    SORASHELL> !ls
    

Limitation

  • sorashell has rough edges, and is not yet suitable for non-technical users. Please note that this is one of my first Go program :)
  • cannot handle parameters in body well e.g. createEventHandler
  • macOS only at this moment. PRs welcome!

Acknowledgements

c-bata/go-prompt and soracom/soracom-cli, which does all the heavy lifting.

Contributing

Please read CONTRIBUTING for details.

License

MIT. See LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Commands = []prompt.Suggest{
	{Text: "audit-logs", Description: "Retrieve audit logs."},
	{Text: "bills", Description: "Show or export billing info."},
	{Text: "cell-locations", Description: "Retrieves cell tower location information."},
	{Text: "coupons", Description: "List or register coupons."},
	{Text: "credentials", Description: "List, create, update or delete credentials sets."},
	{Text: "data", Description: "Get stored data from subscribers."},
	{Text: "devices", Description: "Manage devices."},
	{Text: "diagnostics", Description: "Do diagnostics and get the reports."},
	{Text: "emails", Description: "Manage email addresses."},
	{Text: "event-handlers", Description: "List, create, update or delete event handlers."},
	{Text: "files", Description: "Manage files on Harvest Files."},
	{Text: "gadgets", Description: "Manage gadgets."},
	{Text: "groups", Description: "List, create, update or delete groups."},
	{Text: "help", Description: "Help about any command"},
	{Text: "lagoon", Description: "Manage Lagoon settings."},
	{Text: "logout", Description: "Revoke API key and API token to access to the SORACOM API."},
	{Text: "logs", Description: "List logs."},
	{Text: "lora-devices", Description: "Manage LoRa devices."},
	{Text: "lora-gateways", Description: "Manage LoRa gateways."},
	{Text: "lora-network-sets", Description: "Manage LoRa network sets."},
	{Text: "operator", Description: "Manage operators."},
	{Text: "orders", Description: "List, create or cancel orders."},
	{Text: "payer-information", Description: "Get or edit payer information."},
	{Text: "payment-history", Description: "List payment history."},
	{Text: "payment-methods", Description: "Create or update payment methods."},
	{Text: "payment-statements", Description: "List or export payment statements."},
	{Text: "port-mappings", Description: "Manage port mappings for on-demand remote access."},
	{Text: "products", Description: "List products."},
	{Text: "query", Description: "Search resources such as subscribers or sigfox devices."},
	{Text: "resource-summaries", Description: "Get resource summary."},
	{Text: "roles", Description: "List, create, update or delete roles."},
	{Text: "sandbox", Description: "Sandbox related operations."},
	{Text: "self-update", Description: "Updates soracom-cli to the latest version."},
	{Text: "shipping-addresses", Description: "List, create, update or delete shipping addresses."},
	{Text: "sigfox-devices", Description: "Manage Sigfox devices."},
	{Text: "sims", Description: "Manage SIMs."},
	{Text: "sora-cam", Description: "Manage Soracom Cloud Camera Services (SoraCam) devices and licenses."},
	{Text: "soralets", Description: "Manage Soralets for Orbit."},
	{Text: "stats", Description: "Show or export statistics."},
	{Text: "subscribers", Description: "Manage subscribers."},
	{Text: "system-notifications", Description: "Manage system notifications."},
	{Text: "unconfigure", Description: "Remove configurations."},
	{Text: "users", Description: "Manage SAM users."},
	{Text: "version", Description: "Show version info."},
	{Text: "volume-discounts", Description: "Manage volume discounts (long-term discounts)."},
	{Text: "vpg", Description: "List, create, update or delete VPGs."},
}

Commands define top-level commands from API definition

Functions

This section is empty.

Types

type SoracomCompleter

type SoracomCompleter struct {
	// contains filtered or unexported fields
}

SoracomCompleter returns suggestions for given go-prompt document.

func NewSoracomCompleter

func NewSoracomCompleter(apiDefPath string, worker *SoracomWorker) *SoracomCompleter

NewSoracomCompleter returns a SoracomCompleter which is based on api definition loaded from given apiDefPath.

func (*SoracomCompleter) Complete

func (s *SoracomCompleter) Complete(d prompt.Document) []prompt.Suggest

Complete returns suggestions for given Document.

type SoracomExecutor

type SoracomExecutor struct {
	// contains filtered or unexported fields
}

SoracomExecutor executes given string with the shell.

func NewSoracomExecutor

func NewSoracomExecutor(worker *SoracomWorker) *SoracomExecutor

NewSoracomExecutor returns a SoracomExecutor which executes commands with shell.

func (*SoracomExecutor) Execute

func (e *SoracomExecutor) Execute(s string)

Execute executes given string in the shell.

type SoracomWorker

type SoracomWorker struct {
	// contains filtered or unexported fields
}

SoracomWorker executes given string with the shell.

func NewSoracomWorker

func NewSoracomWorker(shell, profileName, coverageType, apiKey, apiToken string) *SoracomWorker

NewSoracomWorker returns a SoracomExecutor which executes commands with shell.

func (*SoracomWorker) Execute

func (w *SoracomWorker) Execute(s string) string

Execute executes given string after simple parse

Directories

Path Synopsis
cmd
scripts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL