зеркало из https://github.com/golang/dep.git
First pass at normalizing help texts
- short/long should not embed leading/trailing newlines - Normalize grammar in short texts, and remove trailing periods - Remove tabs from strings that will be printed to terminal - Use tabwriter to print table of subcommands
This commit is contained in:
Родитель
1eed2b857c
Коммит
4327a2c2c3
38
ensure.go
38
ensure.go
|
@ -23,14 +23,11 @@ import (
|
|||
)
|
||||
|
||||
var ensureCmd = &command{
|
||||
fn: runEnsure,
|
||||
name: "ensure",
|
||||
flag: flag.NewFlagSet("", flag.ExitOnError),
|
||||
short: `[flags] <path>[:alt location][@<version specifier>]
|
||||
To ensure a dependency is in your project at a specific version (if specified).
|
||||
`,
|
||||
long: `
|
||||
Run it when
|
||||
fn: runEnsure,
|
||||
name: "ensure",
|
||||
flag: flag.NewFlagSet("", flag.ExitOnError),
|
||||
short: `Ensure a dependency is the vendor directory of the current project`,
|
||||
long: `Run it when
|
||||
To ensure a new dependency is in your project.
|
||||
To ensure a dependency is updated.
|
||||
To the latest version that satisfies constraints.
|
||||
|
@ -52,31 +49,30 @@ Print what changed
|
|||
|
||||
|
||||
Flags:
|
||||
-update update all packages
|
||||
-n dry run
|
||||
-override <specs> specify an override constraints for package(s)
|
||||
-update update all packages
|
||||
-n dry run
|
||||
-override <specs> specify an override constraints for package(s)
|
||||
|
||||
|
||||
Package specs:
|
||||
<path>[:alt location][@<version specifier>]
|
||||
|
||||
<path>[:alt location][@<version specifier>]
|
||||
|
||||
Examples:
|
||||
Fetch/update github.com/heroku/rollrus to latest version, including transitive dependencies (ensuring it matches the constraints of rollrus, or—if not contrained—their latest versions):
|
||||
$ dep ensure github.com/heroku/rollrus
|
||||
$ dep ensure github.com/heroku/rollrus
|
||||
Same dep, but choose any minor patch release in the 0.9.X series, setting the constraint. If another constraint exists that constraint is changed to ~0.9.0:
|
||||
$ dep ensure github.com/heroku/rollrus@~0.9.0
|
||||
$ dep ensure github.com/heroku/rollrus@~0.9.0
|
||||
Same dep, but choose any release >= 0.9.1 and < 1.0.0, setting/changing constraints:
|
||||
$ dep ensure github.com/heroku/rollrus@^0.9.1
|
||||
$ dep ensure github.com/heroku/rollrus@^0.9.1
|
||||
Same dep, but updating to 1.0.X:
|
||||
$ dep ensure github.com/heroku/rollrus@~1.0.0
|
||||
$ dep ensure github.com/heroku/rollrus@~1.0.0
|
||||
Same dep, but fetching from a different location:
|
||||
$ dep ensure github.com/heroku/rollrus:git.example.com/foo/bar
|
||||
$ dep ensure github.com/heroku/rollrus:git.example.com/foo/bar
|
||||
Same dep, but check out a specific version or range without updating the Manifest and update the Lockfile. This will fail if the specified version does not satisfy any existing constraints:
|
||||
$ dep ensure github.com/heroku/rollrus==1.2.3 # 1.2.3 specifically
|
||||
$ dep ensure github.com/heroku/rollrus=^1.2.0 # >= 1.2.0 < 2.0.0
|
||||
$ dep ensure github.com/heroku/rollrus==1.2.3 # 1.2.3 specifically
|
||||
$ dep ensure github.com/heroku/rollrus=^1.2.0 # >= 1.2.0 < 2.0.0
|
||||
Override any declared dependency range of 'github.com/foo/bar' to have the range of '^0.9.1'. This applies transitively:
|
||||
$ dep ensure -override github.com/foo/bar@^0.9.1
|
||||
$ dep ensure -override github.com/foo/bar@^0.9.1
|
||||
|
||||
|
||||
Transitive deps are ensured based on constraints in the local Manifest if they exist, then constraints in the dependency’s Manifest file. A lack of constraints defaults to the latest version, eg "^2".
|
||||
|
|
48
init.go
48
init.go
|
@ -17,33 +17,29 @@ import (
|
|||
)
|
||||
|
||||
var initCmd = &command{
|
||||
fn: runInit,
|
||||
name: "init",
|
||||
short: `
|
||||
Write Manifest file in the root of the project directory.
|
||||
`,
|
||||
long: `
|
||||
Populates Manifest file with current deps of this project.
|
||||
The specified version of each dependent repository is the version
|
||||
available in the user's workspaces (as specified by GOPATH).
|
||||
If the dependency is not present in any workspaces it is not be
|
||||
included in the Manifest.
|
||||
Writes Lock file(?)
|
||||
Creates vendor/ directory(?)
|
||||
fn: runInit,
|
||||
name: "init",
|
||||
short: `Write manifest and lock files for the current project`,
|
||||
long: `Populates Manifest file with current deps of this project.
|
||||
The specified version of each dependent repository is the version
|
||||
available in the user's workspaces (as specified by GOPATH).
|
||||
If the dependency is not present in any workspaces it is not be
|
||||
included in the Manifest.
|
||||
Writes Lock file(?)
|
||||
Creates vendor/ directory(?)
|
||||
|
||||
Notes from DOC:
|
||||
Reads existing dependency information written by other tools.
|
||||
Noting any information that is lost (unsupported features, etc).
|
||||
This functionality will be removed after a transition period (1 year?).
|
||||
Write Manifest file in the root of the project directory.
|
||||
* Populates Manifest file with current deps of this project.
|
||||
The specified version of each dependent repository is the version available in the user's workspaces (including vendor/ directories, if present).
|
||||
If the dependency is not present in any workspaces it will not be included in the Manifest. A warning will be issued for these dependencies.
|
||||
Creates vendor/ directory (if it does not exist)
|
||||
Copies the project’s dependencies from the workspace to the vendor/ directory (if they’re not already there).
|
||||
Writes a Lockfile in the root of the project directory.
|
||||
Invoke “dep status”.
|
||||
`,
|
||||
Notes from DOC:
|
||||
Reads existing dependency information written by other tools.
|
||||
Noting any information that is lost (unsupported features, etc).
|
||||
This functionality will be removed after a transition period (1 year?).
|
||||
Write Manifest file in the root of the project directory.
|
||||
* Populates Manifest file with current deps of this project.
|
||||
The specified version of each dependent repository is the version available in the user's workspaces (including vendor/ directories, if present).
|
||||
If the dependency is not present in any workspaces it will not be included in the Manifest. A warning will be issued for these dependencies.
|
||||
Creates vendor/ directory (if it does not exist)
|
||||
Copies the project’s dependencies from the workspace to the vendor/ directory (if they’re not already there).
|
||||
Writes a Lockfile in the root of the project directory.
|
||||
Invoke “dep status”.`,
|
||||
}
|
||||
|
||||
func runInit(args []string) error {
|
||||
|
|
27
main.go
27
main.go
|
@ -11,6 +11,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/sdboyer/gps"
|
||||
)
|
||||
|
@ -107,11 +108,9 @@ func init() {
|
|||
// Defeat circular declarations by appending
|
||||
// this to the list at init time.
|
||||
commands = append(commands, &command{
|
||||
fn: help,
|
||||
name: "help",
|
||||
short: `[command]
|
||||
Show documentation for the dep tool or the specified command.
|
||||
`,
|
||||
fn: help,
|
||||
name: "help",
|
||||
short: `Show documentation for the dep tool or the specified command`,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -122,11 +121,16 @@ func help(args []string) error {
|
|||
}
|
||||
if len(args) == 0 {
|
||||
// Show short usage for all commands.
|
||||
fmt.Printf("usage: dep <command> [arguments]\n\n")
|
||||
fmt.Printf("Available commands:\n\n")
|
||||
fmt.Println("usage: dep <command> [arguments]")
|
||||
fmt.Println()
|
||||
fmt.Println("Available commands:")
|
||||
fmt.Println()
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
|
||||
for _, cmd := range commands {
|
||||
fmt.Printf("%s %s\n", cmd.name, cmd.short)
|
||||
fmt.Fprintf(w, "\t%s\t%s\n", cmd.name, cmd.short)
|
||||
}
|
||||
w.Flush()
|
||||
fmt.Println()
|
||||
return nil
|
||||
}
|
||||
// Show full help for a specific command.
|
||||
|
@ -134,7 +138,12 @@ func help(args []string) error {
|
|||
if cmd.name != args[0] {
|
||||
continue
|
||||
}
|
||||
fmt.Printf("usage: dep %s %s%s\n", cmd.name, cmd.short, cmd.long)
|
||||
fmt.Printf("usage: dep %s\n", cmd.name)
|
||||
fmt.Println()
|
||||
fmt.Printf("%s\n", cmd.short)
|
||||
fmt.Println()
|
||||
fmt.Println(cmd.long)
|
||||
fmt.Println()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown command: %q", args[0])
|
||||
|
|
20
remove.go
20
remove.go
|
@ -15,13 +15,10 @@ import (
|
|||
)
|
||||
|
||||
var removeCmd = &command{
|
||||
fn: runRemove,
|
||||
name: "rm",
|
||||
short: `[flags] [packages]
|
||||
Remove a package or a set of packages.
|
||||
`,
|
||||
long: `
|
||||
Run it when:
|
||||
fn: runRemove,
|
||||
name: "rm",
|
||||
short: `Remove one or more dependencies from the current project`,
|
||||
long: `Run it when:
|
||||
To stop using dependencies
|
||||
To clean out unused dependencies
|
||||
|
||||
|
@ -35,11 +32,10 @@ During removal, dependencies that were only present because of the dependencies
|
|||
Note: this is a separate command to 'ensure' because we want the user to be explicit when making destructive changes.
|
||||
|
||||
Flags:
|
||||
-n Dry run, don’t actually remove anything
|
||||
-unused Remove dependencies that are not used by this project
|
||||
-force Remove dependency even if it is used by the project
|
||||
-keep-source Do not remove source code
|
||||
`,
|
||||
-n Dry run, don’t actually remove anything
|
||||
-unused Remove dependencies that are not used by this project
|
||||
-force Remove dependency even if it is used by the project
|
||||
-keep-source Do not remove source code`,
|
||||
}
|
||||
|
||||
func runRemove(args []string) error {
|
||||
|
|
82
status.go
82
status.go
|
@ -16,53 +16,47 @@ import (
|
|||
)
|
||||
|
||||
var statusCmd = &command{
|
||||
fn: runStatus,
|
||||
name: "status",
|
||||
short: `[flags] [packages]
|
||||
Report the status of the current project's dependencies.
|
||||
`,
|
||||
long: `
|
||||
If no packages are specified, for each dependency:
|
||||
- root import path
|
||||
- (if present in lock) the currently selected version
|
||||
- (else) that it's missing from the lock
|
||||
- whether it's present in the vendor directory (or if it's in
|
||||
workspace, if that's a thing?)
|
||||
- the current aggregate constraints on that project (as specified by
|
||||
the Manifest)
|
||||
- if -u is specified, whether there are newer versions of this
|
||||
dependency
|
||||
fn: runStatus,
|
||||
name: "status",
|
||||
short: `Report the status of the current project's dependencies`,
|
||||
long: `If no packages are specified, for each dependency:
|
||||
- root import path
|
||||
- (if present in lock) the currently selected version
|
||||
- (else) that it's missing from the lock
|
||||
- whether it's present in the vendor directory (or if it's in
|
||||
workspace, if that's a thing?)
|
||||
- the current aggregate constraints on that project (as specified by
|
||||
the Manifest)
|
||||
- if -u is specified, whether there are newer versions of this
|
||||
dependency
|
||||
|
||||
If packages are specified, or if -a is specified,
|
||||
for each of those dependencies:
|
||||
- (if present in lock) the currently selected version
|
||||
- (else) that it's missing from the lock
|
||||
- whether it's present in the vendor directory
|
||||
- The set of possible versions for that project
|
||||
- The upstream source URL(s) from which the project may be retrieved
|
||||
- The type of upstream source (git, hg, bzr, svn, registry)
|
||||
- Other versions that might work, given the current constraints
|
||||
- The list of all projects that import the project within the current
|
||||
depgraph
|
||||
- The current constraint. If more than one project constrains it, both
|
||||
the aggregate and the individual components (and which project provides
|
||||
that constraint) are printed
|
||||
- License information
|
||||
- Package source location, if fetched from an alternate location
|
||||
If packages are specified, or if -a is specified,
|
||||
for each of those dependencies:
|
||||
- (if present in lock) the currently selected version
|
||||
- (else) that it's missing from the lock
|
||||
- whether it's present in the vendor directory
|
||||
- The set of possible versions for that project
|
||||
- The upstream source URL(s) from which the project may be retrieved
|
||||
- The type of upstream source (git, hg, bzr, svn, registry)
|
||||
- Other versions that might work, given the current constraints
|
||||
- The list of all projects that import the project within the current
|
||||
depgraph
|
||||
- The current constraint. If more than one project constrains it, both
|
||||
the aggregate and the individual components (and which project provides
|
||||
that constraint) are printed
|
||||
- License information
|
||||
- Package source location, if fetched from an alternate location
|
||||
|
||||
Flags:
|
||||
-json Output in json format
|
||||
-f [template] Output in text/template format
|
||||
Flags:
|
||||
-json Output in JSON format
|
||||
-f [template] Output in text/template format
|
||||
-old Only show out of date packages and the current version
|
||||
-missing Only show missing packages
|
||||
-unused Only show unused packages
|
||||
-modified Only show modified packages
|
||||
-dot Export dependency graph in GraphViz format
|
||||
|
||||
-old Only show out of date packages and the current version
|
||||
-missing Only show missing packages.
|
||||
-unused Only show unused packages.
|
||||
-modified Only show modified packages.
|
||||
|
||||
-dot Export dependency graph in GraphViz format
|
||||
|
||||
The exit code of status is zero if all repositories are in a "good state".
|
||||
`,
|
||||
The exit code of status is zero if all repositories are in a "good state".`,
|
||||
}
|
||||
|
||||
// BasicStatus contains all the information reported about a single dependency
|
||||
|
|
Загрузка…
Ссылка в новой задаче