Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.
/ cmd Public archive

🐢 package cmd provides a microframework for building CLI tools integrated with Temporal configuration

License

Notifications You must be signed in to change notification settings

RTradeLtd/cmd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecated: This is no longer maintained, and all projects will eventually be migrated to urfave/cli. It is recommend that you use urfave/cli as opposed to cmd as it is a much more extensible, and feature complete system.

🐢 cmd GoDoc Build Status codecov Go Report Card

Package cmd provides a microframework for building CLI tools integrated with Temporal configuration.

It is extremely lightweight, with only a single dependency - package config, which contains Temporal's configuration definitions.

Usage

import (
  "github.com/RTradeLtd/cmd"
  "github.com/RTradeLtd/config"
)

// define commands
var commands = map[string]cmd.Cmd{
  "api": cmd.Cmd{
    Blurb:       "start Temporal api server",
    Description: "Start the API service used to interact with Temporal. Run with DEBUG=true to enable debug messages.",
    Action: func(cfg config.TemporalConfig, args map[string]string) { /* ... */ },
  },
  "queue": cmd.Cmd{
    Blurb:         "execute commands for various queues",
    Description:   "Interact with Temporal's various queue APIs",
    ChildRequired: true,
    Children: map[string]cmd.Cmd{
      "ipns-entry": cmd.Cmd{
        Blurb:       "IPNS entry creation queue",
        Description: "Listens to requests to create IPNS records",
        Action: func(cfg config.TemporalConfig, args map[string]string) { /* ... */ },
      },
    },
  },
}

// entrypoint
func main() {
  // create app
  temporal := cmd.New(commands, cmd.Config{
    Name:     "Temporal",
    ExecName: "temporal",
    Version:  Version,
    Desc:     "Temporal is an easy-to-use interface into distributed and decentralized storage technologies for personal and enterprise use cases.",
  })

  // run no-config commands. exit if a command was executed
  if exit := temporal.PreRun(os.Args[1:]); exit == cmd.CodeOK {
    os.Exit(0)
  }

  // load config
  tCfg, _ := config.LoadConfig("path/to/config")

  // load arguments
  flags := map[string]string{ /* ... */ }

  // execute
  os.Exit(temporal.Run(*tCfg, flags, os.Args[1:]))
}

About

🐢 package cmd provides a microframework for building CLI tools integrated with Temporal configuration

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages