Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor docs and help text improvements #66

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmdget.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

var getCommand = &Command{
UsageLine: "get [-vcs] [-u] [-f] [module...]",
UsageLine: "get [-vcs] [-f] [module...]",
Short: "start hacking a module",
Long: `
The get command checks out Go module dependencies
Expand All @@ -37,7 +37,7 @@ func init() {

var (
// TODO implement getUpdate so that we can use gohack -f without
// overwriting source code.
// overwriting source code. When we do, add [-u] to the lists of flags that get takes.
// getUpdate = getCommand.Flag.Bool("u", false, "update to current version")
getForce = getCommand.Flag.Bool("f", false, "force update to current version even if not clean")
getVCS = getCommand.Flag.Bool("vcs", false, "get VCS information too")
Expand Down
2 changes: 1 addition & 1 deletion help.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package main

import (
"fmt"
"html/template"
"io"
"os"
"strings"
"text/template"
)

// runHelp implements the 'help' command.
Expand Down
26 changes: 0 additions & 26 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,6 @@ import (
"gopkg.in/errgo.v2/fmt/errors"
)

/*
As the amount of functionality grows, it seems like we should consider having subcommands.

A possible set of commands:

gohack get [-vcs] [-u] [-f] [module...]
Get gets the modules at the current version and adds replace statements to the go.mod file if they're not already replaced.
If the -u flag is provided, the source code will also be updated to the current version if it's clean.
If the -f flag is provided with -u, the source code will be updated even if it's not clean.
If the -vcs flag is provided, it also checks out VCS information for the modules. If the modules were already gohacked in non-VCS mode, gohack switches them to VCS mode, preserving any changes made (this might result in the directory moving).

With no module arguments and the -u flag, it will try to update all currently gohacked modules.

gohack status
Status prints a list of the replaced modules

gohack rm [-f] module...
Rm removes the gohack directory if it is clean and then runs gohack undo. If the -f flag is provided, the directory is removed even if it's not clean.

gohack undo [module...]
Undo removes the replace statements for the modules. If no modules are provided, it will undo all gohack replace statements. The gohack module directories are unaffected.

gohack dir [-vcs] [module...]
Dir prints the gohack module directory names for the given modules. If no modules are given, all the currently gohacked module directories are printed. If the -vcs flag is provided, the directory to be used in VCS mode is printed. Unlike the other subcommands, the modules don't need to be referenced by the current module.
*/

var (
printCommands = flag.Bool("x", false, "show executed commands")
dryRun = flag.Bool("n", false, "print but do not execute update commands")
Expand Down
4 changes: 2 additions & 2 deletions testdata/help.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# --help flag produces output to stderr and fails
! gohack get --help
stderr '^usage: get \[-vcs] \[-u] \[-f] \[module...]\nRun ''gohack help get'' for details.\n'
stderr '^usage: get \[-vcs] \[-f] \[module...]\nRun ''gohack help get'' for details.\n'
! stdout .+

gohack help get
stdout '^usage: get \[-vcs] \[-u] \[-f] \[module...]$'
stdout '^usage: get \[-vcs] \[-f] \[module...]$'
! stderr .+