Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/lwiles/termite

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/lwiles/termite

  • v0.0.0-20241030155121-e526cd151286
  • Source
  • Go
  • Socket score

Version published
Created
Source

Termite

docs build codecov

Termite is a collection of utilities for building CLI tools in Go.

A few things to note:

  • This is still a WIP. I'm in the process of extracting things here when I find reusable patterns that I'm repeating often. This probably won't be stable or useful for others for a while, so... use at your own risk :grimacing: (at least until a 1.0 release).
  • Some of these packages were inspired or copied from the GitHub CLI project. I'm a big fan :heart: and I've done my best to give proper attribution per the license. If anyone from that team feels I've misappropriated anything, please let me know and I'll try to make amends.

Install

go get github.com/twelvelabs/termite

Usage

package main

import (
    "github.com/twelvelabs/termite/api"
    "github.com/twelvelabs/termite/conf"
    "github.com/twelvelabs/termite/ui"
)

func main() {
    type Config struct {
        BaseURL string `default:"https://0.0.0.0/api/v1" validate:"required,url"`
        Debug   bool   `default:"true"`
    }

    // Loads and validates config values from ~/.config/my-app/config.yaml
    config, _ := conf.NewLoader(&Config{}, ConfigFile("my-app")).Load()
    client := api.NewRESTClient(&api.ClientOptions{
        BaseURL: config.BaseURL,
    })

    type APIResponse struct {
        Status string `json:"statusMessage"`
    }

    u := ui.NewUserInterface(ui.NewIOStreams())
    ok, _ := u.Confirm("Proceed?", true, "Some help text...")
    if ok {
        u.ProgressIndicator.Start("Requesting")
        resp := &APIResponse{}
        err := client.Get("/some/endpoint", resp)
        if err != nil {
            u.Out(u.FailureIcon() + " API failure: %v\n", err)
        } else {
            u.Out(u.InfoIcon() + " API success: %v\n", resp.Status)
        }
        u.ProgressIndicator.Stop()
    }
    u.Out(u.SuccessIcon() + " Done\n")
}

Output:

? Proceed? Yes
• API success: some status message
✓ Done

Development

git clone git@github.com:twelvelabs/termite.git
cd termite

make setup
make build
make test

# Show full usage
make

FAQs

Package last updated on 30 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc