Example #1
1
package main

import (
	"encoding/json"
	"io/ioutil"
	"log"
	"os"
	"time"

	kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var (
	Version = "0.1.0"
	app     = kingpin.New("files", "Command for listing a file in JSON")
	appPath = app.Flag("path", "path to list").Required().Short('s').String()
)

type ShortFileInfo struct {
	Name    string
	Size    int64
	IsDir   bool
	IsLink  bool
	ModTime time.Time
}

func NewShortFileInfo(f os.FileInfo) *ShortFileInfo {
	fi := ShortFileInfo{}
	fi.Name = f.Name()
	fi.Size = f.Size()
	fi.IsDir = f.IsDir()
Example #2
0
package main

import (
	"io"
	"os"
	"unicode/utf8"

	log "github.com/Sirupsen/logrus"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
)

// Command line options.
var (
	cli             = kingpin.New("cntblank", "Count blank cells on text-based tabular data.")
	cliVerbose      = cli.Flag("verbose", "Set verbose mode on.").Short('v').Bool()
	cliInEncoding   = cli.Flag("input-encoding", "Input encoding.").Short('e').String()
	cliOutEncoding  = cli.Flag("output-encoding", "Output encoding.").Short('E').String()
	cliInDelimiter  = cli.Flag("input-delimiter", "Input field delimiter.").String()
	cliOutDelimiter = cli.Flag("output-delimiter", "Output field delmiter.").String()
	cliNoHeader     = cli.Flag("without-header", "Tabular does not have header line.").Bool()
	cliOutNoHeader  = cli.Flag("output-without-header", "Output report does not have header line.").Bool()
	cliStrict       = cli.Flag("strict", "Check column size strictly.").Bool()
	cliSheet        = cli.Flag("sheet", "Excel sheet number which starts with 1.").Int()
	cliOutMeta      = cli.Flag("output-meta", "Put meta information.").Bool()
	cliOutput       = cli.Flag("output", "Output file.").Short('o').String()
	cliOutFormat    = cli.Flag("output-format", "Output format.").String()
	cliTabularFiles = cli.Arg("tabfile", "Tabular data files.").ExistingFiles()
)

func main() {
	log.SetOutput(os.Stderr)
Example #3
0
	"log"
	"os"
	"runtime"
	"strconv"
	"sync"

	kingpin "gopkg.in/alecthomas/kingpin.v2"

	a "github.com/chrislusf/glow/agent"
	r "github.com/chrislusf/glow/netchan/receiver"
	s "github.com/chrislusf/glow/netchan/sender"
	m "github.com/chrislusf/glow/resource/service_discovery/master"
)

var (
	app = kingpin.New("glow", "A command-line net channel.")

	master     = app.Command("master", "Start a master process")
	masterPort = master.Flag("port", "listening port").Default("8930").Int()
	masterIp   = master.Flag("ip", "listening IP adress").Default("localhost").String()

	agent       = app.Command("agent", "Channel Agent")
	agentOption = &a.AgentServerOption{
		Dir:          agent.Flag("dir", "agent folder to store computed data").Default(os.TempDir()).String(),
		Port:         agent.Flag("port", "agent listening port").Default("8931").Int(),
		Master:       agent.Flag("master", "master address").Default("localhost:8930").String(),
		DataCenter:   agent.Flag("dataCenter", "data center name").Default("defaultDataCenter").String(),
		Rack:         agent.Flag("rack", "rack name").Default("defaultRack").String(),
		MaxExecutor:  agent.Flag("max.executors", "upper limit of executors").Default(strconv.Itoa(runtime.NumCPU())).Int(),
		CPULevel:     agent.Flag("cpu.level", "relative computing power of single cpu core").Default("1").Int(),
		MemoryMB:     agent.Flag("memory", "memory size in MB").Default("1024").Int64(),
import (
	"bytes"
	"crypto/rand"
	"fmt"
	"github.com/dedis/crypto/abstract"
	"github.com/dedis/crypto/edwards/ed25519"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	"io/ioutil"
	"net"
	"os"
	"vennard.ch/crypto"
)

/* variables for sigcli3. Try sigcli3 --help to see what you should be passing */
var (
	app               = kingpin.New("sigcli3", "Client for partially blind signature scheme implementation")
	appPrivatekeyfile = app.Arg("privatekey", "Path to schnorr public key").Required().String()
	appInfo           = app.Arg("info", "Output file path to write (appends .pub, .pri)").Required().String()
	appHostspec       = app.Arg("host", "Listen on port").Required().String()
)

/* this function loads the random binary blob used as the
   blind key and specified in path
*/
func LoadInfo(path string) ([]byte, error) {
	fcontents, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}
	return fcontents, nil
}
Example #5
0
	// Description
	Description = ""

	// Version application version number
	Version = "0.1.0"
)

var (
	// Build SHA
	Build string

	// TimeFormat global time format string
	TimeFormat = "15:04:05"

	app           = kingpin.New(Name, Description)
	debug         = app.Flag("debug", "Enable debug logging.").Short('v').Bool()
	dev           = app.Flag("dev", "Enable dev mode.").Bool()
	quiet         = app.Flag("quiet", "Remove all output logging.").Short('q').Bool()
	appSSL        = app.Flag("ssl", "Enable SSL (useful outside nginx/apache).").Short('s').Bool()
	appConfigPath = app.Flag("config", "Config path (default is ~/.codetainer/config.toml or /etc/codetainer/config.toml)").Short('c').String()

	server = app.Command("server", "Start the Codetainer API server.")

	profileCommand         = app.Command("profile", "Profile commands")
	profileListCommand     = profileCommand.Command("list", "List profiles")
	profileRegisterCommand = profileCommand.Command("register", "Register a profile")
	profileRegisterPath    = profileRegisterCommand.Arg("path", "Path to load of JSON profile").Required().String()
	profileRegisterName    = profileRegisterCommand.Arg("name", "name of profile").Required().String()

	imageCommand       = app.Command("image", "Image commands")
	"fmt"
	"github.com/dedis/crypto/edwards/ed25519"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	"io/ioutil"
	"net"
	"os"
	"vennard.ch/crypto"
)

/* These variables form the command line parameters of the keytool utility.
   The kingpin processor is much more to my liking than just about any
   other I've seen in a couple of languages - even boost::program_options isn't quite
   this good.
*/
var (
	app               = kingpin.New("sigserv3", "Blind signature server - signs (partially blindly) a message provided by sigcli3")
	appPrivatekeyfile = app.Arg("privatekey", "Path to schnorr private key").Required().String()
	appInfo           = app.Arg("info", "Output file path to write (appends .pub, .pri)").Required().String()
	appPort           = app.Arg("port", "Listen on port").Int()
)

func LoadInfo(path string) ([]byte, error) {
	fcontents, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}
	return fcontents, nil
}

/* runs through the process of setting up the server as specified in the args */
func main() {
Example #7
0
	"github.com/kylef/result.go/src/result"
	kp "gopkg.in/alecthomas/kingpin.v2"
	gc "libgitcomment"
	"math"
	"os"
)

const (
	defaultContextLines = 3
	linesBeforeConfig   = "comment.logBefore"
	linesAfterConfig    = "comment.logAfter"
)

var (
	buildVersion     string
	app              = kp.New("git-comment-log", "List git commit comments")
	fullDiff         = app.Flag("full-diff", "Show the full diff surrounding the comments").Bool()
	pretty           = app.Flag("pretty", "Pretty-print the comments in a format such as short, full, raw, or custom placeholders.").String()
	enablePager      = app.Flag("pager", "Use pager (Default)").Default("true").Bool()
	enableColor      = app.Flag("color", "Use color (Default)").Default("true").Bool()
	enableMarginLine = app.Flag("margin-line", "Use margin line (Default)").Default("true").Bool()
	lineNumbers      = app.Flag("line-numbers", "Show line numbers").Bool()
	linesBefore      = app.Flag("lines-before", "Number of context lines to show before comments").Short('B').Int64()
	linesAfter       = app.Flag("lines-after", "Number of context lines to show after comments").Short('A').Int64()
	revision         = app.Arg("revision range", "Filter comments to comments on commits from the specified range").String()
	contextLines     uint32
)

func main() {
	app.Version(buildVersion)
	kp.MustParse(app.Parse(os.Args[1:]))
package main

import (
	//    "crypto/rand"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	"os"
	//    "github.com/dedis/crypto/edwards/ed25519"
	//    "vennard.ch/crypto"
)

// because kingpin worked so nicely in the keytool, let's use it again:

var (
	app        = kingpin.New("sigcli2", "Command line client for multisignature schnorr")
	configFile = app.Arg("config", "Read the group configuration from this file").Required().String()
)

func main() {
	kingpin.MustParse(app.Parse(os.Args[1:]))

	runClientProtocol(*configFile)
}
Example #9
0
package main

import (
	"fmt"
	gg "git"
	"github.com/kylef/result.go/src/result"
	kp "gopkg.in/alecthomas/kingpin.v2"
	gc "libgitcomment"
	"os"
)

var (
	buildVersion string
	app          = kp.New("git-comment", "Add comments to commits and diffs within git repositories")
	message      = app.Flag("message", "comment content").Short('m').String()
	amendID      = app.Flag("amend", "ID of a comment to amend").String()
	deleteID     = app.Flag("delete", "ID of a comment to delete").String()
	commit       = app.Flag("commit", "ID of a commit to annotate").Short('c').String()
	author       = app.Flag("author", "Override the comment author").String()
	update       = app.Flag("update", "Upgrade repository to use current version of git-comment").Bool()
	fileref      = app.Arg("file:line", "File and line number to annotate").String()
	markDeleted  = app.Flag("mark-deleted-line", "Add comment to the deleted version of the file and line number").Bool()
)

func main() {
	app.Version(buildVersion)
	kp.MustParse(app.Parse(os.Args[1:]))
	pwd, err := os.Getwd()
	app.FatalIfError(err, "pwd")
	if *update {
		gc.VersionUpdate(pwd, buildVersion)
Example #10
0
package main

import (
	"fmt"
	"github.com/kylef/result.go/src/result"
	kp "gopkg.in/alecthomas/kingpin.v2"
	gc "libgitcomment"
	"os"
)

var (
	buildVersion  string
	app           = kp.New("git-comment-remote", "Helper commands for the merge workflow")
	configCmd     = app.Command("config", "Configure remote to fetch and push comments by default")
	configRemote  = configCmd.Arg("remote", "Remote to configure").Required().String()
	deleteCmd     = app.Command("delete", "Delete remote copy of a comment")
	deleteRemote  = deleteCmd.Arg("remote", "Remote from which to delete comment").Required().String()
	deleteComment = deleteCmd.Arg("comment", "Comment to delete").Required().String()
)

func main() {
	app.Version(buildVersion)
	pwd, err := os.Getwd()
	app.FatalIfError(err, "pwd")
	fatalIfError(app, gc.VersionCheck(pwd, buildVersion), "version")
	switch kp.MustParse(app.Parse(os.Args[1:])) {
	case "config":
		app.FatalIfError(gc.ConfigureRemoteForComments(pwd, *configRemote).Failure, "git")
		fmt.Printf("Remote '%v' updated\n", *configRemote)
	case "delete":
		app.FatalIfError(gc.DeleteRemoteComment(pwd, *deleteRemote, *deleteComment).Failure, "git")
	"bytes"
	"crypto/rand"
	"fmt"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	"os"
	"strconv"
	"strings"
)

/* These variables form the command line parameters of the keytool utility.
   The kingpin processor is much more to my liking than just about any
   other I've seen in a couple of languages - even boost::program_options isn't quite
   this good.
*/
var (
	app = kingpin.New("keytool", "Command line keygen tool for Schnorr work")

	genCmd       = app.Command("gen", "Generate a new server instance pub,pri keypair")
	genCmdOutput = genCmd.Arg("output", "Output file path to write (appends .pub, .pri)").Required().String()

	groupCmd       = app.Command("mkgroup", "Create a Schnorr Multisignature group configuration file")
	groupCmdOutput = groupCmd.Arg("output", "Write the output file to this path").Required().String()
	groupCmdHost   = groupCmd.Arg("host:port,pathtokey", "triplet  indicating host to add").Required().Strings()

	randomInfCmd       = app.Command("raninf", "Generate a random blob of shared information for Partially-Blind")
	randomInfCmdOutput = randomInfCmd.Arg("output", "Output file path to write").Required().String()
)

/* this function is effectively dd if=/dev/urandom of=$PATH bs=1 count=16
   that is, we copy 16 bytes of cryptographically secure random junk to
   the output file. The only reason for this is for convenience
Example #12
0
File: main.go Project: dz0ny/gobu
import (
	"fmt"
	"gobu/remote"
	"os"
	"os/exec"
	"path/filepath"
	"runtime"

	log "github.com/Sirupsen/logrus"
	ps "github.com/mitchellh/go-ps"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var build = "dev"

var app = kingpin.New("gobu", "Bootstrap your GOlang enviroment")
var showVerbose = app.Flag("debug", "Verbose mode.").Bool()

var shell = app.Command("shell", "Start a shell with Golang enviroment.").Default()
var shellVersion = shell.Flag("release", "Override Golang version used in new shell").String()

var versions = app.Command("versions", "List of all supported Golang releases.")

var goPath = ""
var envPath = ".gobu"

func init() {
	p, err := os.Getwd()
	if err != nil {
		log.Fatal(err)
	}
Example #13
0
package main

import (
	gx "exec"
	"fmt"
	gg "git"
	"github.com/kylef/result.go/src/result"
	kp "gopkg.in/alecthomas/kingpin.v2"
	gc "libgitcomment"
	"os"
)

var (
	buildVersion string
	app          = kp.New("git-comment-grep", "Index and look for comments")
	findCmd      = app.Command("find", "Look for comments containing text")
	indexCmd     = app.Command("index", "Index and cache comment content")
	noPager      = app.Flag("nopager", "Disable pager").Bool()
	noColor      = app.Flag("nocolor", "Disable color").Bool()
	text         = findCmd.Arg("text", "Search text").Required().String()
)

func main() {
	app.Version(buildVersion)
	pwd, err := os.Getwd()
	app.FatalIfError(err, "pwd")
	fatalIfError(app, gc.VersionCheck(pwd, buildVersion), "version")
	switch kp.MustParse(app.Parse(os.Args[1:])) {
	case "find":
		findText(pwd, *text)
	case "index":
Example #14
0
package sacloud

import (
	kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var ExitCode = 0

var (
	cli  = kingpin.New("jj", "Yet another unofficial Sacloud CLI")
	json = kingpin.Flag("json", "Output the raw json response body of the API").Bool()
	tsv  = kingpin.Flag("tsv", "Output as tsv format(default)").Bool()

	servers = cli.Command("servers", "List servers")

	api       = cli.Command("api", "Support sending a request to API")
	apiMethod = api.Arg("method", "HTTP Verb: get, put, post, delete").Required().String()
	apiPath   = api.Arg("path", "Path: /server").Required().String()
)

type OuputFormat struct {
	JSON, TSV bool
}

const VERSION = "0.0.1"

func Run(args []string) {
	kingpin.CommandLine.HelpFlag.Short('h')
	kingpin.Version(VERSION)

	opFmt := &OuputFormat{JSON: *json, TSV: *tsv}