base

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package base defines shared xtype pieces of the gop command, in particular logging and the Command structure.

Index

Constants

This section is empty.

Variables

View Source
var (
	BuildContext = defaultContext()
	// BuildMod         string // -mod flag
	BuildModExplicit bool // whether -mod was set explicitly
	BuildX           bool // -x flag
	BuildV           bool // -v flag
	BuildSSA         bool // -ssa flag
	DebugSSATrace    bool // -ssa-trace flag
	ExperimentalGC   bool // -exp-gc flag experimental support runtime.GC
)
View Source
var CmdName string

CmdName - "build", "install", "list", "mod tidy", etc.

View Source
var Igop = &Command{
	UsageLine: "igop",
	Short:     `igop is a SSA interpreter of Go/Go+ source code.`,
}

igop command

View Source
var Usage func()

Usage is the usage-reporting function, filled in by package main but here for reference by other packages.

Functions

func AddBuildFlags added in v0.8.7

func AddBuildFlags(cmd *Command, mask BuildFlagMask)

AddBuildFlags adds the flags common to the build, run, and test commands.

func Main

func Main(c *Command, app string, args []string)

Main runs a command.

Types

type BuildFlagMask added in v0.8.7

type BuildFlagMask int
const (
	DefaultBuildFlags BuildFlagMask = 0
	OmitModFlag       BuildFlagMask = 1 << iota
	OmitVFlag
	OmitSSAFlag
	OmitSSATraceFlag
	OmitExperimentalGCFlag
)

type Command

type Command struct {
	// Run runs the command.
	// The args are the arguments after the command name.
	Run func(cmd *Command, args []string)

	// UsageLine is the one-line usage message.
	// The words between "gop" and the first flag or argument in the line are taken to be the command name.
	UsageLine string

	// Short is the short description shown in the 'gop help' output.
	Short string

	// Flag is a set of flags specific to this command.
	Flag flag.FlagSet

	// Commands lists the available commands and help topics.
	// The order here is the order in which they are printed by 'gop help'.
	// Note that subcommands are in general best avoided.
	Commands []*Command
}

A Command is an implementation of a gop command like gop export or gop install.

func (*Command) LongName

func (c *Command) LongName() string

LongName returns the command's long name: all the words in the usage line between "gop" and a flag or argument,

func (*Command) Name

func (c *Command) Name() string

Name returns the command's short name: the last word in the usage line before a flag or argument.

func (*Command) Runnable

func (c *Command) Runnable() bool

Runnable reports whether the command can be run; otherwise it is a documentation pseudo-command.

func (*Command) Usage

func (c *Command) Usage(w io.Writer)

Usage show the command usage.

Jump to

Keyboard shortcuts

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