{"modulePath":"github.com/sourcegraph/srclib","version":"v0.2.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cli\n\n## Variables\n\n```go\nvar (\n\n\t// CacheLocalRepo controls whether OpenLocalRepo caches the\n\t// results of OpenRepo the first time it runs and returns the same\n\t// repo for all subsequent calls (even if you call os.Chdir, for\n\t// example).\n\tCacheLocalRepo = true\n)\n```\n\n```go\nvar GlobalOpt struct {\n\tVerbose bool `short:\"v\" description:\"show verbose output\"`\n}\n```\nGlobalOpt contains global options.\n\n```go\nvar OpenStore func() (interface{}, error) = storeCmd.store\n```\nOpenStore is called by all of the store subcommands to open the store.\n\n```go\nvar Version = \"dev\"\n```\nVersion of srclib.\n\nFor releases, this is set using the -X flag to \\`go tool ld\\`. See [http://stackoverflow.com/a/11355611](http://stackoverflow.com/a/11355611).\n\n## Functions\n\n```go\nfunc AddCommands(c *flags.Command)\n```\nAddCommands adds all of the \"srclib ...\" subcommands (toolchain, tool, make, etc.) as subcommands on c.\n\nIt is used to create the \"srclib\" command, but it can also be used to mount the srclib CLI underneath any other CLI tool's command, such as \"mytool srclib ...\".\n\n```go\nfunc ColorizeDiff(diff []byte) []byte\n```\nColorizeDiff takes a byte slice of lines and returns the same, but with diff highlighting. That is, lines starting with '+' are green and lines starting with '-' are red.\n\n```go\nfunc CreateMakefile() (*makex.Makefile, error)\n```\nCreateMakefile creates a Makefile to build a tree. The cwd should be the root of the tree you want to make (due to some probably unnecessary assumptions that CreateMaker makes).\n\n```go\nfunc GetBuildDataFS(commitID string) (rwvfs.FileSystem, error)\n```\n\n```go\nfunc Import(buildDataFS vfs.FileSystem, stor interface{}, opt ImportOpt) error\n```\nImport imports build data into a RepoStore or MultiRepoStore.\n\n```go\nfunc InitStoreCmds(c *flags.Command)\n```\n\n```go\nfunc Main() error\n```\n\n```go\nfunc PrintJSON(v interface{}, prefix string)\n```\n\n```go\nfunc SetDefaultCommitIDOpt(c *flags.Command)\n```\n\n```go\nfunc SetOptionDefaultValue(g *flags.Group, longName string, defaultVal ...string)\n```\n\n## Types\n\n```go\ntype ConfigCmd struct {\n\tOutput struct {\n\t\tOutput string `short:\"o\" long:\"output\" description:\"output format\" default:\"text\" value-name:\"text|json\"`\n\t} `group:\"output\"`\n\n\tArgs struct {\n\t\tDir Directory `name:\"DIR\" default:\".\" description:\"root directory of tree to configure\"`\n\t} `positional-args:\"yes\"`\n\n\tQuiet bool `short:\"q\" long:\"quiet\" description:\"silence all output\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (c *ConfigCmd) Execute(args []string) error\n```\n\n```go\ntype CoverageCmd struct {\n}\n```\n\n```go\nfunc (c *CoverageCmd) Execute(args []string) error\n```\n\n```go\ntype DiffCmd struct {\n\tArgs struct {\n\t\tExpFile string `name:\"expfile\" description:\"expected file\"`\n\t\tActFile string `name:\"actfile\" description:\"actual file\"`\n\t} `positional-args:\"yes\"`\n}\n```\nTODO(beyang): should have TestCmd use this in checkResults to give more helpful output\n\n```go\nfunc (c *DiffCmd) Execute(args []string) error\n```\n\n```go\ntype Directory string\n```\nDirectory is flags.Completer that provides directory name completion. Do not convert Directory to a string type manually, always use Directory.String(). Only use Directory for go-flags.Command fields, not for internal functions.\n\nTODO(sqs): this is annoying. it only completes the dir name and doesn't let you keep typing the arg.\n\n```go\nfunc (d Directory) Complete(match string) []flags.Completion\n```\nComplete implements flags.Completer and returns a list of existing directories with the given prefix.\n\n```go\nfunc (d Directory) String() string\n```\nString returns the uncleaned string representation of d. If d is empty, \".\" is returned. Never convert Directories to strings manually, always call String.\n\n```go\ntype DoAllCmd struct {\n\tDir Directory `short:\"C\" long:\"directory\" description:\"change to DIR before doing anything\" value-name:\"DIR\"`\n}\n```\n\n```go\nfunc (c *DoAllCmd) Execute(args []string) error\n```\n\n```go\ntype ImportOpt struct {\n\tDryRun  bool `short:\"n\" long:\"dry-run\" description:\"print what would be done but don't do anything\"`\n\tNoIndex bool `long:\"no-index\" description:\"don't build indexes (indexes inside a single source unit are always built)\"`\n\n\tRepo     string `long:\"repo\" description:\"only import for this repo\"`\n\tUnit     string `long:\"unit\" description:\"only import source units with this name\"`\n\tUnitType string `long:\"unit-type\" description:\"only import source units with this type\"`\n\tCommitID string `long:\"commit\" description:\"commit ID of commit whose data to import\"`\n\n\tVerbose bool\n}\n```\n\n```go\ntype InfoCmd struct{}\n```\n\n```go\nfunc (c *InfoCmd) Execute(args []string) error\n```\n\n```go\ntype LintCmd struct {\n\tRepo string `short:\"r\" long:\"repo\" description:\"repository URI (defaults to VCS 'srclib' or 'origin' remote URL)\"`\n\n\tNoCheckFiles   bool `long:\"no-check-files\" description:\"don't check that file/dir fields refer to actual files\"`\n\tNoCheckResolve bool `long:\"no-check-resolve\" description:\"don't check that internal refs resolve to existing defs\"`\n\n\tArgs struct {\n\t\tPaths []string `name:\"PATH\" description:\"path to srclib JSON output file, or a directory tree of such\"`\n\t} `positional-args:\"YES\"`\n}\n```\n\n```go\nfunc (c *LintCmd) Execute(args []string) error\n```\n\n```go\ntype MakeCmd struct {\n\tQuiet  bool `short:\"q\" long:\"quiet\" description:\"silence all output\"`\n\tDryRun bool `short:\"n\" long:\"dry-run\" description:\"print what would be done and exit\"`\n\n\tParallel int `short:\"j\" long:\"jobs\" description:\"allow N parallel jobs\" value-name:\"N\" default-mask:\"GOMAXPROCS\"`\n\n\tDir Directory `short:\"C\" long:\"directory\" description:\"change to DIR before doing anything\" value-name:\"DIR\"`\n\n\tArgs struct {\n\t\tGoals []string `name:\"GOALS...\" description:\"Makefile targets to build (default: all)\"`\n\t} `positional-args:\"yes\"`\n}\n```\n\n```go\nfunc (c *MakeCmd) Execute(args []string) error\n```\n\n```go\ntype MakefileCmd struct{}\n```\n\n```go\nfunc (c *MakefileCmd) Execute(args []string) error\n```\n\n```go\ntype NormalizeGraphDataCmd struct {\n\tUnitType string `long:\"unit-type\" description:\"source unit type (e.g., GoPackage)\"`\n\tDir      string `long:\"dir\" description:\"directory of source unit (SourceUnit.Dir field)\"`\n}\n```\n\n```go\nfunc (c *NormalizeGraphDataCmd) Execute(args []string) error\n```\n\n```go\ntype Repo struct {\n\tRootDir  string // Root directory containing repository being analyzed\n\tVCSType  string // VCS type (git or hg)\n\tCommitID string // CommitID of current working directory\n}\n```\n\n```go\nfunc OpenLocalRepo() (*Repo, error)\n```\nOpenLocalRepo opens the VCS repository in or above the current directory.\n\n```go\nfunc OpenRepo(dir string) (*Repo, error)\n```\n\n```go\ntype SelfUpdateCmd struct {\n\tCheckOnly bool `short:\"n\" long:\"check-only\" description:\"check for update but do not download and install it\"`\n}\n```\n\n```go\nfunc (c *SelfUpdateCmd) Execute(_ []string) error\n```\n\n```go\ntype StoreCmd struct {\n\tType   string `short:\"t\" long:\"type\" description:\"the (multi-)repo store type to use (RepoStore, MultiRepoStore, etc.)\" default:\"RepoStore\"`\n\tRoot   string `short:\"r\" long:\"root\" description:\"the root of the store (repo clone dir for RepoStore, global path for MultiRepoStore, etc.)\" default:\".srclib-store\"`\n\tConfig string `long:\"config\" description:\"(rarely used) JSON-encoded config for extra config, specific to each store type\"`\n}\n```\n\n```go\nfunc (c *StoreCmd) Execute(args []string) error\n```\n\n```go\ntype StoreDefsCmd struct {\n\tRepo     string `long:\"repo\"`\n\tPath     string `long:\"path\"`\n\tUnitType string `long:\"unit-type\" `\n\tUnit     string `long:\"unit\"`\n\tFile     string `long:\"file\"`\n\tCommitID string `long:\"commit\"`\n\n\tRepoCommitIDs string `long:\"repo-commits\" description:\"comma-separated list of repo@commitID specifiers\"`\n\n\tQuery string `long:\"query\"`\n\n\tLimit  int `short:\"n\" long:\"limit\" description:\"max results to return (0 for all)\"`\n\tOffset int `long:\"offset\" description:\"results offset (0 to start with first results)\"`\n\n\t// If Filter is non-nil, it is applied along with the above\n\t// filters.\n\tFilter store.DefFilter\n}\n```\n\n```go\nfunc (c *StoreDefsCmd) Execute(args []string) error\n```\n\n```go\nfunc (c *StoreDefsCmd) Get() ([]*graph.Def, error)\n```\n\n```go\ntype StoreImportCmd struct {\n\tImportOpt\n\n\tQuiet bool `short:\"q\" long:\"quiet\" description:\"silence all output\"`\n\n\tSample           bool `long:\"sample\" description:\"(sample data) import sample data, not .srclib-cache data\"`\n\tSampleDefs       int  `long:\"sample-defs\" description:\"(sample data) number of sample defs to import\" default:\"100\"`\n\tSampleRefs       int  `long:\"sample-refs\" description:\"(sample data) number of sample refs to import\" default:\"100\"`\n\tSampleImportOnly bool `long:\"sample-import-only\" description:\"(sample data) only import, don't demonstrate listing data\"`\n}\n```\n\n```go\nfunc (c *StoreImportCmd) Execute(args []string) error\n```\n\n```go\ntype StoreIndexCmd struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (c *StoreIndexCmd) Execute(args []string) error\n```\n\n```go\nfunc (c StoreIndexCmd) IndexCriteria() store.IndexCriteria\n```\n\n```go\ntype StoreIndexesCmd struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (c *StoreIndexesCmd) Execute(args []string) error\n```\n\n```go\nfunc (c StoreIndexesCmd) IndexCriteria() store.IndexCriteria\n```\n\n```go\ntype StoreRefsCmd struct {\n\tRepo     string `long:\"repo\"`\n\tUnitType string `long:\"unit-type\" `\n\tUnit     string `long:\"unit\"`\n\tFile     string `long:\"file\"`\n\tCommitID string `long:\"commit\"`\n\n\tRepoCommitIDs string `long:\"repo-commits\" description:\"comma-separated list of repo@commitID specifiers\"`\n\n\tStart uint32 `long:\"start\"`\n\tEnd   uint32 `long:\"end\"`\n\n\tDefRepo     string `long:\"def-repo\"`\n\tDefUnitType string `long:\"def-unit-type\" `\n\tDefUnit     string `long:\"def-unit\"`\n\tDefPath     string `long:\"def-path\"`\n\n\tBroken   bool `long:\"broken\" description:\"only show refs that point to nonexistent defs\"`\n\tCoverage bool `long:\"coverage\" description:\"print a coverage summary (resolved refs, broken refs, total refs)\"`\n\n\tFormat string `long:\"format\" description:\"output format ('json' or 'none')\" default:\"json\"`\n\n\tLimit  int `short:\"n\" long:\"limit\" description:\"max results to return (0 for all)\"`\n\tOffset int `long:\"offset\" description:\"results offset (0 to start with first results)\"`\n}\n```\n\n```go\nfunc (c *StoreRefsCmd) Execute(args []string) error\n```\n\n```go\nfunc (c *StoreRefsCmd) Get() ([]*graph.Ref, error)\n```\n\n```go\ntype StoreReposCmd struct {\n\tIDContains string `short:\"i\" long:\"id-contains\" description:\"filter to repos whose ID contains this substring\"`\n}\n```\n\n```go\nfunc (c *StoreReposCmd) Execute(args []string) error\n```\n\n```go\ntype StoreUnitsCmd struct {\n\tType     string `long:\"type\" `\n\tName     string `long:\"name\"`\n\tCommitID string `long:\"commit\"`\n\tRepo     string `long:\"repo\"`\n\n\tRepoCommitIDs string `long:\"repo-commits\" description:\"comma-separated list of repo@commitID specifiers\"`\n\n\tFile string `long:\"file\" description:\"filter by units whose Files list contains this file\"`\n}\n```\n\n```go\nfunc (c *StoreUnitsCmd) Execute(args []string) error\n```\n\n```go\ntype StoreVersionsCmd struct {\n\tRepo           string `long:\"repo\"`\n\tCommitIDPrefix string `long:\"commit\" description:\"commit ID prefix\"`\n\n\tRepoCommitIDs string `long:\"repo-commits\" description:\"comma-separated list of repo@commitID specifiers\"`\n}\n```\n\n```go\nfunc (c *StoreVersionsCmd) Execute(args []string) error\n```\n\n```go\ntype TestCmd struct {\n\tGenerateExpected bool `long:\"gen\" description:\"(re)generate expected output for all test cases and exit\"`\n\n\tArgs struct {\n\t\tTrees []Directory `name:\"TREES\" description:\"trees to treat as test cases\"`\n\t} `positional-args:\"yes\"`\n}\n```\n\n```go\nfunc (c *TestCmd) Execute(args []string) error\n```\n\n```go\ntype ToolCmd struct {\n\tArgs struct {\n\t\tToolchain ToolchainPath `name:\"TOOLCHAIN\" description:\"toolchain path of the toolchain to run\"`\n\t\tTool      ToolName      `name:\"TOOL\" description:\"tool subcommand name to run (in TOOLCHAIN)\"`\n\t\tToolArgs  []string      `name:\"ARGS\" description:\"args to pass to TOOL\"`\n\t} `positional-args:\"yes\" required:\"yes\"`\n}\n```\n\n```go\nfunc (c *ToolCmd) Execute(args []string) error\n```\n\n```go\ntype ToolName string\n```\n\n```go\nfunc (t ToolName) Complete(match string) []flags.Completion\n```\n\n```go\ntype ToolchainBundleCmd struct {\n\tVariant string `long:\"variant\" description:\"only produce a bundle for the given variant (default is all variants)\"`\n\tDryRun  bool   `short:\"n\" long:\"dry-run\" description:\"don't do anything, but print what would be done\"`\n\n\tArgs struct {\n\t\tToolchain ToolchainPath `name:\"TOOLCHAIN\" description:\"toolchain to bundle\" required:\"yes\"`\n\t\tDir       string        `name:\"TOOLCHAIN-DIR\" description:\"dir containing toolchain files (default: look up TOOLCHAIN in SRCLIBPATH)\"`\n\t} `positional-args:\"yes\"`\n}\n```\n\n```go\nfunc (c *ToolchainBundleCmd) Execute(args []string) error\n```\n\n```go\ntype ToolchainCmd struct{}\n```\n\n```go\nfunc (c *ToolchainCmd) Execute(args []string) error\n```\n\n```go\ntype ToolchainInstallCmd struct {\n\t// Args are not required so we can print out a more detailed\n\t// error message inside (*ToolchainInstallCmd).Execute.\n\tArgs struct {\n\t\tLanguages []string `value-name:\"LANG\" description:\"language toolchains to install\"`\n\t} `positional-args:\"yes\"`\n}\n```\n\n```go\nfunc (c *ToolchainInstallCmd) Execute(args []string) error\n```\n\n```go\ntype ToolchainListCmd struct {\n}\n```\n\n```go\nfunc (c *ToolchainListCmd) Execute(args []string) error\n```\n\n```go\ntype ToolchainListToolsCmd struct {\n\tOp             string `short:\"p\" long:\"op\" description:\"only list tools that perform these operations only\" value-name:\"OP\"`\n\tSourceUnitType string `short:\"u\" long:\"source-unit-type\" description:\"only list tools that operate on this source unit type\" value-name:\"TYPE\"`\n\tArgs           struct {\n\t\tToolchains []ToolchainPath `name:\"TOOLCHAINS\" description:\"only list tools in these toolchains\"`\n\t} `positional-args:\"yes\" required:\"yes\"`\n}\n```\n\n```go\nfunc (c *ToolchainListToolsCmd) Execute(args []string) error\n```\n\n```go\ntype ToolchainPath string\n```\n\n```go\nfunc (t ToolchainPath) Complete(match string) []flags.Completion\n```\n\n```go\ntype ToolchainUnbundleCmd struct {\n\tArgs struct {\n\t\tToolchain  string `name:\"TOOLCHAIN\" description:\"toolchain path to unbundle to\"`\n\t\tBundleFile string `name:\"BUNDLE-FILE\" description:\"bundle file containing toolchain dir contents (.tar.gz, .tar, etc.)\"`\n\t} `positional-args:\"yes\" required:\"yes\"`\n}\n```\n\n```go\nfunc (c *ToolchainUnbundleCmd) Execute(args []string) error\n```\n\n```go\ntype UnitsCmd struct {\n\tOutput struct {\n\t\tOutput string `short:\"o\" long:\"output\" description:\"output format\" default:\"text\" value-name:\"text|json\"`\n\t} `group:\"output\"`\n\n\tArgs struct {\n\t\tDir Directory `name:\"DIR\" default:\".\" description:\"root directory of tree to list units in\"`\n\t} `positional-args:\"yes\"`\n}\n```\n\n```go\nfunc (c *UnitsCmd) Execute(args []string) error\n```\n\n","path":"github.com/sourcegraph/srclib/cli","name":"cli","synopsis":"","isRedistributable":true}
