mirror of
https://github.com/x-motemen/ghq.git
synced 2026-09-10 07:26:27 -04:00
Update urfave/cli/v2 to v3
This commit is contained in:
parent
c71ae6ae4b
commit
7dff4b0aa8
135
CREDITS
135
CREDITS
|
|
@ -117,33 +117,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
================================================================
|
||||
|
||||
github.com/cpuguy83/go-md2man/v2
|
||||
https://github.com/cpuguy83/go-md2man/v2
|
||||
----------------------------------------------------------------
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Brian Goff
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
================================================================
|
||||
|
||||
github.com/davecgh/go-spew
|
||||
https://github.com/davecgh/go-spew
|
||||
----------------------------------------------------------------
|
||||
|
|
@ -379,6 +352,46 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
SOFTWARE.
|
||||
================================================================
|
||||
|
||||
github.com/otiai10/copy
|
||||
https://github.com/otiai10/copy
|
||||
----------------------------------------------------------------
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 otiai10
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
================================================================
|
||||
|
||||
github.com/otiai10/mint
|
||||
https://github.com/otiai10/mint
|
||||
----------------------------------------------------------------
|
||||
Copyright 2017 otiai10 (Hiromu OCHIAI)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
================================================================
|
||||
|
||||
github.com/pmezard/go-difflib
|
||||
https://github.com/pmezard/go-difflib
|
||||
----------------------------------------------------------------
|
||||
|
|
@ -412,41 +425,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
================================================================
|
||||
|
||||
github.com/russross/blackfriday/v2
|
||||
https://github.com/russross/blackfriday/v2
|
||||
----------------------------------------------------------------
|
||||
Blackfriday is distributed under the Simplified BSD License:
|
||||
|
||||
> Copyright © 2011 Russ Ross
|
||||
> All rights reserved.
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without
|
||||
> modification, are permitted provided that the following conditions
|
||||
> are met:
|
||||
>
|
||||
> 1. Redistributions of source code must retain the above copyright
|
||||
> notice, this list of conditions and the following disclaimer.
|
||||
>
|
||||
> 2. Redistributions in binary form must reproduce the above
|
||||
> copyright notice, this list of conditions and the following
|
||||
> disclaimer in the documentation and/or other materials provided with
|
||||
> the distribution.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
> "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
> LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
> FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
> COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
> INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
> BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
> LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
> LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
> ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
> POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
================================================================
|
||||
|
||||
github.com/saracen/walker
|
||||
https://github.com/saracen/walker
|
||||
----------------------------------------------------------------
|
||||
|
|
@ -500,12 +478,12 @@ SOFTWARE.
|
|||
|
||||
================================================================
|
||||
|
||||
github.com/urfave/cli/v2
|
||||
https://github.com/urfave/cli/v2
|
||||
github.com/urfave/cli/v3
|
||||
https://github.com/urfave/cli/v3
|
||||
----------------------------------------------------------------
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 urfave/cli maintainers
|
||||
Copyright (c) 2023 urfave/cli maintainers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -527,33 +505,6 @@ SOFTWARE.
|
|||
|
||||
================================================================
|
||||
|
||||
github.com/xrash/smetrics
|
||||
https://github.com/xrash/smetrics
|
||||
----------------------------------------------------------------
|
||||
Copyright (C) 2016 Felipe da Cunha Gonçalves
|
||||
All Rights Reserved.
|
||||
|
||||
MIT LICENSE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
================================================================
|
||||
|
||||
golang.org/x/net
|
||||
https://golang.org/x/net
|
||||
----------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func doCreate(c *cli.Context) error {
|
||||
func doCreate(ctx context.Context, cmd *cli.Command) error {
|
||||
var (
|
||||
name = c.Args().First()
|
||||
vcs = c.String("vcs")
|
||||
w = c.App.Writer
|
||||
bare = c.Bool("bare")
|
||||
name = cmd.Args().First()
|
||||
vcs = cmd.String("vcs")
|
||||
w = cmd.Root().Writer
|
||||
bare = cmd.Bool("bare")
|
||||
)
|
||||
|
||||
if name == "" {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -128,7 +129,7 @@ func TestDoCreate(t *testing.T) {
|
|||
|
||||
var err error
|
||||
out, _, _ := capture(func() {
|
||||
err = newApp().Run(append([]string{""}, tc.input...))
|
||||
err = newApp().Run(context.Background(), append([]string{""}, tc.input...))
|
||||
})
|
||||
out = strings.TrimSpace(out)
|
||||
|
||||
|
|
|
|||
29
cmd_get.go
29
cmd_get.go
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
|
@ -13,29 +14,29 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
"github.com/x-motemen/ghq/cmdutil"
|
||||
"github.com/x-motemen/ghq/logger"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
func doGet(c *cli.Context) error {
|
||||
func doGet(ctx context.Context, cmd *cli.Command) error {
|
||||
var (
|
||||
args = c.Args().Slice()
|
||||
andLook = c.Bool("look")
|
||||
parallel = c.Bool("parallel")
|
||||
silent = c.Bool("silent")
|
||||
args = cmd.Args().Slice()
|
||||
andLook = cmd.Bool("look")
|
||||
parallel = cmd.Bool("parallel")
|
||||
silent = cmd.Bool("silent")
|
||||
)
|
||||
g := &getter{
|
||||
update: c.Bool("update"),
|
||||
shallow: c.Bool("shallow"),
|
||||
ssh: c.Bool("p"),
|
||||
vcs: c.String("vcs"),
|
||||
update: cmd.Bool("update"),
|
||||
shallow: cmd.Bool("shallow"),
|
||||
ssh: cmd.Bool("p"),
|
||||
vcs: cmd.String("vcs"),
|
||||
silent: silent,
|
||||
branch: c.String("branch"),
|
||||
recursive: !c.Bool("no-recursive"),
|
||||
bare: c.Bool("bare"),
|
||||
partial: c.String("partial"),
|
||||
branch: cmd.String("branch"),
|
||||
recursive: !cmd.Bool("no-recursive"),
|
||||
bare: cmd.Bool("bare"),
|
||||
partial: cmd.String("partial"),
|
||||
}
|
||||
if parallel {
|
||||
// force silent in parallel import
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -26,7 +27,7 @@ func TestCommandGet(t *testing.T) {
|
|||
scenario: func(t *testing.T, tmpRoot string, cloneArgs *_cloneArgs, updateArgs *_updateArgs) {
|
||||
localDir := filepath.Join(tmpRoot, "github.com", "motemen", "ghq-test-repo")
|
||||
|
||||
app.Run([]string{"", "get", "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "motemen/ghq-test-repo"})
|
||||
|
||||
expect := "https://github.com/motemen/ghq-test-repo"
|
||||
if cloneArgs.remote.String() != expect {
|
||||
|
|
@ -53,7 +54,7 @@ func TestCommandGet(t *testing.T) {
|
|||
scenario: func(t *testing.T, tmpRoot string, cloneArgs *_cloneArgs, updateArgs *_updateArgs) {
|
||||
localDir := filepath.Join(tmpRoot, "github.com", "motemen", "ghq-test-repo")
|
||||
|
||||
app.Run([]string{"", "get", "-p", "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "-p", "motemen/ghq-test-repo"})
|
||||
|
||||
expect := "ssh://git@github.com/motemen/ghq-test-repo"
|
||||
if cloneArgs.remote.String() != expect {
|
||||
|
|
@ -73,7 +74,7 @@ func TestCommandGet(t *testing.T) {
|
|||
// mark as "already cloned", the condition may change later
|
||||
os.MkdirAll(filepath.Join(localDir, ".git"), 0755)
|
||||
|
||||
app.Run([]string{"", "get", "-update", "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "-update", "motemen/ghq-test-repo"})
|
||||
|
||||
if updateArgs.local != localDir {
|
||||
t.Errorf("got: %s, expect: %s", updateArgs.local, localDir)
|
||||
|
|
@ -84,7 +85,7 @@ func TestCommandGet(t *testing.T) {
|
|||
scenario: func(t *testing.T, tmpRoot string, cloneArgs *_cloneArgs, updateArgs *_updateArgs) {
|
||||
localDir := filepath.Join(tmpRoot, "github.com", "motemen", "ghq-test-repo")
|
||||
|
||||
app.Run([]string{"", "get", "-shallow", "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "-shallow", "motemen/ghq-test-repo"})
|
||||
|
||||
expect := "https://github.com/motemen/ghq-test-repo"
|
||||
if cloneArgs.remote.String() != expect {
|
||||
|
|
@ -106,7 +107,7 @@ func TestCommandGet(t *testing.T) {
|
|||
os.Chdir(localDir)
|
||||
defer os.Chdir(wd)
|
||||
|
||||
app.Run([]string{"", "get", "-update", "." + string(filepath.Separator) + "ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "-update", "." + string(filepath.Separator) + "ghq-test-repo"})
|
||||
|
||||
expect := "https://github.com/motemen/ghq-test-repo"
|
||||
if cloneArgs.remote.String() != expect {
|
||||
|
|
@ -126,7 +127,7 @@ func TestCommandGet(t *testing.T) {
|
|||
os.Chdir(localDir)
|
||||
defer os.Chdir(wd)
|
||||
|
||||
app.Run([]string{"", "get", "-update", ".." + string(filepath.Separator) + "ghq-another-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "-update", ".." + string(filepath.Separator) + "ghq-another-test-repo"})
|
||||
|
||||
expect := "https://github.com/motemen/ghq-another-test-repo"
|
||||
if cloneArgs.remote.String() != expect {
|
||||
|
|
@ -143,7 +144,7 @@ func TestCommandGet(t *testing.T) {
|
|||
localDir := filepath.Join(tmpRoot, "github.com", "motemen", "ghq-test-repo")
|
||||
|
||||
expectBranch := "hello"
|
||||
app.Run([]string{"", "get", "-shallow", "-branch", expectBranch, "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "-shallow", "-branch", expectBranch, "motemen/ghq-test-repo"})
|
||||
|
||||
expect := "https://github.com/motemen/ghq-test-repo"
|
||||
if cloneArgs.remote.String() != expect {
|
||||
|
|
@ -162,7 +163,7 @@ func TestCommandGet(t *testing.T) {
|
|||
localDir := filepath.Join(tmpRoot, "github.com", "motemen", "ghq-test-repo")
|
||||
|
||||
expectBranch := "hello"
|
||||
app.Run([]string{"", "get", "-shallow", "motemen/ghq-test-repo@" + expectBranch})
|
||||
app.Run(context.Background(), []string{"", "get", "-shallow", "motemen/ghq-test-repo@" + expectBranch})
|
||||
|
||||
expect := "https://github.com/motemen/ghq-test-repo"
|
||||
if cloneArgs.remote.String() != expect {
|
||||
|
|
@ -178,7 +179,7 @@ func TestCommandGet(t *testing.T) {
|
|||
}, {
|
||||
name: "with --no-recursive option",
|
||||
scenario: func(t *testing.T, tmpRoot string, cloneArgs *_cloneArgs, updateArgs *_updateArgs) {
|
||||
app.Run([]string{"", "get", "--no-recursive", "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "--no-recursive", "motemen/ghq-test-repo"})
|
||||
|
||||
localDir := filepath.Join(tmpRoot, "github.com", "motemen", "ghq-test-repo")
|
||||
if filepath.ToSlash(cloneArgs.local) != filepath.ToSlash(localDir) {
|
||||
|
|
@ -196,7 +197,7 @@ func TestCommandGet(t *testing.T) {
|
|||
[ghq "https://github.com/motemen"]
|
||||
root = "%s"
|
||||
`, filepath.ToSlash(tmpd))))
|
||||
app.Run([]string{"", "get", "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "motemen/ghq-test-repo"})
|
||||
|
||||
localDir := filepath.Join(tmpd, "github.com", "motemen", "ghq-test-repo")
|
||||
if filepath.ToSlash(cloneArgs.local) != filepath.ToSlash(localDir) {
|
||||
|
|
@ -208,7 +209,7 @@ func TestCommandGet(t *testing.T) {
|
|||
scenario: func(t *testing.T, tmpRoot string, cloneArgs *_cloneArgs, updateArgs *_updateArgs) {
|
||||
localDir := filepath.Join(tmpRoot, "github.com", "motemen", "ghq-test-repo.git")
|
||||
|
||||
app.Run([]string{"", "get", "--bare", "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "--bare", "motemen/ghq-test-repo"})
|
||||
|
||||
expect := "https://github.com/motemen/ghq-test-repo"
|
||||
if cloneArgs.remote.String() != expect {
|
||||
|
|
@ -227,7 +228,7 @@ func TestCommandGet(t *testing.T) {
|
|||
localDir := filepath.Join(tmpRoot, "github.com", "motemen", "ghq-test-repo")
|
||||
|
||||
out, _, err := captureWithInput([]string{}, func() {
|
||||
app.Run([]string{"", "get", "--silent", "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "--silent", "motemen/ghq-test-repo"})
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("error should be nil, but: %s", err)
|
||||
|
|
@ -253,7 +254,7 @@ func TestCommandGet(t *testing.T) {
|
|||
scenario: func(t *testing.T, tmpRoot string, cloneArgs *_cloneArgs, updateArgs *_updateArgs) {
|
||||
localDir := filepath.Join(tmpRoot, "github.com", "motemen", "ghq-test-repo")
|
||||
|
||||
app.Run([]string{"", "get", "--partial", "blobless", "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "--partial", "blobless", "motemen/ghq-test-repo"})
|
||||
|
||||
expect := "https://github.com/motemen/ghq-test-repo"
|
||||
if cloneArgs.remote.String() != expect {
|
||||
|
|
@ -271,7 +272,7 @@ func TestCommandGet(t *testing.T) {
|
|||
scenario: func(t *testing.T, tmpRoot string, cloneArgs *_cloneArgs, updateArgs *_updateArgs) {
|
||||
localDir := filepath.Join(tmpRoot, "github.com", "motemen", "ghq-test-repo")
|
||||
|
||||
app.Run([]string{"", "get", "--partial", "treeless", "motemen/ghq-test-repo"})
|
||||
app.Run(context.Background(), []string{"", "get", "--partial", "treeless", "motemen/ghq-test-repo"})
|
||||
|
||||
expect := "https://github.com/motemen/ghq-test-repo"
|
||||
if cloneArgs.remote.String() != expect {
|
||||
|
|
@ -287,7 +288,7 @@ func TestCommandGet(t *testing.T) {
|
|||
}, {
|
||||
name: "[partial] unacceptable value",
|
||||
scenario: func(t *testing.T, tmpRoot string, cloneArgs *_cloneArgs, updateArgs *_updateArgs) {
|
||||
err := app.Run([]string{"", "get", "--partial", "unacceptable", "motemen/ghq-test-repo"})
|
||||
err := app.Run(context.Background(), []string{"", "get", "--partial", "unacceptable", "motemen/ghq-test-repo"})
|
||||
|
||||
expect := "flag partial value \"unacceptable\" is not allowed"
|
||||
if err.Error() != expect {
|
||||
|
|
@ -318,7 +319,7 @@ func TestLook(t *testing.T) {
|
|||
}
|
||||
sh := detectShell()
|
||||
|
||||
err := newApp().Run([]string{"", "get", "--look", "https://github.com/motemen/ghq"})
|
||||
err := newApp().Run(context.Background(), []string{"", "get", "--look", "https://github.com/motemen/ghq"})
|
||||
if err != nil {
|
||||
t.Errorf("error should be nil, but: %s", err)
|
||||
}
|
||||
|
|
@ -364,7 +365,7 @@ func TestBareLook(t *testing.T) {
|
|||
}
|
||||
sh := detectShell()
|
||||
|
||||
err := newApp().Run([]string{"", "get", "--bare", "--look", "https://github.com/motemen/ghq.git"})
|
||||
err := newApp().Run(context.Background(), []string{"", "get", "--bare", "--look", "https://github.com/motemen/ghq.git"})
|
||||
if err != nil {
|
||||
t.Errorf("error should be nil, but: %s", err)
|
||||
}
|
||||
|
|
@ -426,7 +427,7 @@ func TestDoGet_bulk(t *testing.T) {
|
|||
buf.Reset()
|
||||
out, _, err := captureWithInput(in, func() {
|
||||
args := append([]string{"", "get"}, tc.args...)
|
||||
if err := newApp().Run(args); err != nil {
|
||||
if err := newApp().Run(context.Background(), args); err != nil {
|
||||
t.Errorf("error should be nil but: %s", err)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
19
cmd_list.go
19
cmd_list.go
|
|
@ -1,24 +1,25 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func doList(c *cli.Context) error {
|
||||
func doList(ctx context.Context, cmd *cli.Command) error {
|
||||
var (
|
||||
w = c.App.Writer
|
||||
query = c.Args().First()
|
||||
exact = c.Bool("exact")
|
||||
vcsBackend = c.String("vcs")
|
||||
printFullPaths = c.Bool("full-path")
|
||||
printUniquePaths = c.Bool("unique")
|
||||
bare = c.Bool("bare")
|
||||
w = cmd.Root().Writer
|
||||
query = cmd.Args().First()
|
||||
exact = cmd.Bool("exact")
|
||||
vcsBackend = cmd.String("vcs")
|
||||
printFullPaths = cmd.Bool("full-path")
|
||||
printUniquePaths = cmd.Bool("unique")
|
||||
bare = cmd.Bool("bare")
|
||||
)
|
||||
|
||||
filterByQuery := func(_ *LocalRepository) bool {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
|
@ -9,26 +9,11 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func flagSet(name string, flags []cli.Flag) *flag.FlagSet {
|
||||
set := flag.NewFlagSet(name, flag.ContinueOnError)
|
||||
|
||||
for _, f := range flags {
|
||||
f.Apply(set)
|
||||
}
|
||||
return set
|
||||
}
|
||||
|
||||
func TestCommandList(t *testing.T) {
|
||||
_, _, err := capture(func() {
|
||||
app := cli.NewApp()
|
||||
flagSet := flagSet("list", commandList.Flags)
|
||||
c := cli.NewContext(app, flagSet, nil)
|
||||
|
||||
doList(c)
|
||||
newApp().Run(context.Background(), []string{"ghq", "list"})
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -38,12 +23,7 @@ func TestCommandList(t *testing.T) {
|
|||
|
||||
func TestCommandListUnique(t *testing.T) {
|
||||
_, _, err := capture(func() {
|
||||
app := cli.NewApp()
|
||||
flagSet := flagSet("list", commandList.Flags)
|
||||
flagSet.Parse([]string{"--unique"})
|
||||
c := cli.NewContext(app, flagSet, nil)
|
||||
|
||||
doList(c)
|
||||
newApp().Run(context.Background(), []string{"ghq", "list", "--unique"})
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -53,12 +33,7 @@ func TestCommandListUnique(t *testing.T) {
|
|||
|
||||
func TestCommandListUnknown(t *testing.T) {
|
||||
_, _, err := capture(func() {
|
||||
app := cli.NewApp()
|
||||
flagSet := flagSet("list", commandList.Flags)
|
||||
flagSet.Parse([]string{"--unknown-flag"})
|
||||
c := cli.NewContext(app, flagSet, nil)
|
||||
|
||||
doList(c)
|
||||
newApp().Run(context.Background(), []string{"ghq", "list", "--unknown-flag"})
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -158,7 +133,7 @@ func TestDoList_query(t *testing.T) {
|
|||
t.Run(tc.name, func(t *testing.T) {
|
||||
args := append([]string{"ghq", "list"}, tc.args...)
|
||||
out, _, _ := capture(func() {
|
||||
newApp().Run(args)
|
||||
newApp().Run(context.Background(), args)
|
||||
})
|
||||
if !equalPathLines(out, tc.expect) {
|
||||
t.Errorf("got:\n%s\nexpect:\n%s", out, tc.expect)
|
||||
|
|
@ -177,7 +152,7 @@ func TestDoList_query(t *testing.T) {
|
|||
fullExpect += "\n"
|
||||
}
|
||||
out, _, _ = capture(func() {
|
||||
newApp().Run(argsFull)
|
||||
newApp().Run(context.Background(), argsFull)
|
||||
})
|
||||
if !equalPathLines(out, fullExpect) {
|
||||
t.Errorf("got:\n%s\nexpect:\n%s", out, fullExpect)
|
||||
|
|
@ -201,7 +176,7 @@ func TestDoList_unique(t *testing.T) {
|
|||
os.MkdirAll(filepath.Join(rootPath, "github.com/motemen/ghq/.git"), 0755)
|
||||
}
|
||||
out, _, _ := capture(func() {
|
||||
newApp().Run([]string{"ghq", "list", "--unique"})
|
||||
newApp().Run(context.Background(), []string{"ghq", "list", "--unique"})
|
||||
})
|
||||
if out != "ghq\n" {
|
||||
t.Errorf("got: %s, expect: ghq\n", out)
|
||||
|
|
@ -214,7 +189,7 @@ func TestDoList_unknownRoot(t *testing.T) {
|
|||
_localRepositoryRoots = nil
|
||||
localRepoOnce = &sync.Once{}
|
||||
|
||||
err := newApp().Run([]string{"ghq", "list"})
|
||||
err := newApp().Run(context.Background(), []string{"ghq", "list"})
|
||||
if err != nil {
|
||||
t.Errorf("error should be nil, but: %v", err)
|
||||
}
|
||||
|
|
@ -233,7 +208,7 @@ func TestDoList_notPermittedRoot(t *testing.T) {
|
|||
localRepoOnce = &sync.Once{}
|
||||
os.Chmod(tmpdir, 0000)
|
||||
|
||||
err := newApp().Run([]string{"ghq", "list"})
|
||||
err := newApp().Run(context.Background(), []string{"ghq", "list"})
|
||||
if err != nil {
|
||||
t.Errorf("error should be nil, but: %+v", err)
|
||||
}
|
||||
|
|
@ -253,7 +228,7 @@ func TestDoList_withSystemHiddenDir(t *testing.T) {
|
|||
_localRepositoryRoots = nil
|
||||
localRepoOnce = &sync.Once{}
|
||||
|
||||
err := newApp().Run([]string{"ghq", "list"})
|
||||
err := newApp().Run(context.Background(), []string{"ghq", "list"})
|
||||
if err != nil {
|
||||
t.Errorf("error should be nil, but: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
|
@ -10,16 +11,16 @@ import (
|
|||
"syscall"
|
||||
|
||||
"github.com/otiai10/copy"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
"github.com/x-motemen/ghq/logger"
|
||||
)
|
||||
|
||||
func doMigrate(c *cli.Context) error {
|
||||
func doMigrate(ctx context.Context, cmd *cli.Command) error {
|
||||
var (
|
||||
repoDir = c.Args().First()
|
||||
dry = c.Bool("dry-run")
|
||||
skipConfirm = c.Bool("y")
|
||||
w = c.App.Writer
|
||||
repoDir = cmd.Args().First()
|
||||
dry = cmd.Bool("dry-run")
|
||||
skipConfirm = cmd.Bool("y")
|
||||
w = cmd.Root().Writer
|
||||
)
|
||||
|
||||
if repoDir == "" {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
|
@ -65,7 +66,7 @@ func TestDoMigrate(t *testing.T) {
|
|||
c2.Run()
|
||||
|
||||
a := newApp()
|
||||
e := a.Run([]string{"ghq", "migrate", "-y", srcdir})
|
||||
e := a.Run(context.Background(), []string{"ghq", "migrate", "-y", srcdir})
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
|
|
@ -79,7 +80,7 @@ func TestDoMigrate(t *testing.T) {
|
|||
// Test case: nonexistent directory
|
||||
t.Run("migrate_nonexist", func(t *testing.T) {
|
||||
a := newApp()
|
||||
e := a.Run([]string{"ghq", "migrate", "-y", "/does/not/exist"})
|
||||
e := a.Run(context.Background(), []string{"ghq", "migrate", "-y", "/does/not/exist"})
|
||||
if e == nil {
|
||||
t.Error("expected error")
|
||||
}
|
||||
|
|
@ -99,7 +100,7 @@ func TestDoMigrate(t *testing.T) {
|
|||
c2.Run()
|
||||
|
||||
a := newApp()
|
||||
e := a.Run([]string{"ghq", "migrate", "--dry-run", srcdir})
|
||||
e := a.Run(context.Background(), []string{"ghq", "migrate", "--dry-run", srcdir})
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
|
|
@ -117,7 +118,7 @@ func TestDoMigrate(t *testing.T) {
|
|||
addWorktree(t, srcdir, wtDir, "wt-branch")
|
||||
|
||||
a := newApp()
|
||||
e := a.Run([]string{"ghq", "migrate", "-y", srcdir})
|
||||
e := a.Run(context.Background(), []string{"ghq", "migrate", "-y", srcdir})
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
|
|
@ -154,7 +155,7 @@ func TestDoMigrate(t *testing.T) {
|
|||
|
||||
out, _, err := capture(func() {
|
||||
a := newApp()
|
||||
a.Run([]string{"ghq", "migrate", "--dry-run", srcdir})
|
||||
a.Run(context.Background(), []string{"ghq", "migrate", "--dry-run", srcdir})
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -180,7 +181,7 @@ func TestDoMigrate(t *testing.T) {
|
|||
addWorktree(t, srcdir, wtDir, "wt-int-branch")
|
||||
|
||||
a := newApp()
|
||||
e := a.Run([]string{"ghq", "migrate", "-y", srcdir})
|
||||
e := a.Run(context.Background(), []string{"ghq", "migrate", "-y", srcdir})
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
|
|
@ -226,7 +227,7 @@ func TestMigrateEdgeCases(t *testing.T) {
|
|||
os.MkdirAll(srcdir, 0755)
|
||||
|
||||
a := newApp()
|
||||
e := a.Run([]string{"ghq", "migrate", "-y", srcdir})
|
||||
e := a.Run(context.Background(), []string{"ghq", "migrate", "-y", srcdir})
|
||||
if e == nil {
|
||||
t.Error("should fail when no VCS found")
|
||||
}
|
||||
|
|
@ -241,7 +242,7 @@ func TestMigrateEdgeCases(t *testing.T) {
|
|||
c.Run()
|
||||
|
||||
a := newApp()
|
||||
e := a.Run([]string{"ghq", "migrate", "-y", srcdir})
|
||||
e := a.Run(context.Background(), []string{"ghq", "migrate", "-y", srcdir})
|
||||
if e == nil {
|
||||
t.Error("should fail when no remote")
|
||||
}
|
||||
|
|
@ -263,7 +264,7 @@ func TestMigrateEdgeCases(t *testing.T) {
|
|||
os.MkdirAll(dest, 0755)
|
||||
|
||||
a := newApp()
|
||||
e := a.Run([]string{"ghq", "migrate", "-y", srcdir})
|
||||
e := a.Run(context.Background(), []string{"ghq", "migrate", "-y", srcdir})
|
||||
if e == nil {
|
||||
t.Error("should fail when dest exists")
|
||||
}
|
||||
|
|
@ -276,7 +277,7 @@ func TestMigrateEdgeCases(t *testing.T) {
|
|||
addWorktree(t, srcdir, wtDir, "wt-ref-branch")
|
||||
|
||||
a := newApp()
|
||||
e := a.Run([]string{"ghq", "migrate", "-y", wtDir})
|
||||
e := a.Run(context.Background(), []string{"ghq", "migrate", "-y", wtDir})
|
||||
if e == nil {
|
||||
t.Fatal("expected error migrating a worktree")
|
||||
}
|
||||
|
|
@ -299,7 +300,7 @@ func TestMigrateEdgeCases(t *testing.T) {
|
|||
os.WriteFile(repoFile, []byte("test-repo\n"), 0644)
|
||||
|
||||
a := newApp()
|
||||
e := a.Run([]string{"ghq", "migrate", "-y", srcdir})
|
||||
e := a.Run(context.Background(), []string{"ghq", "migrate", "-y", srcdir})
|
||||
if e == nil {
|
||||
t.Error("should fail for unsupported VCS (CVS)")
|
||||
}
|
||||
|
|
|
|||
13
cmd_rm.go
13
cmd_rm.go
|
|
@ -1,18 +1,19 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func doRm(c *cli.Context) error {
|
||||
func doRm(ctx context.Context, cmd *cli.Command) error {
|
||||
var (
|
||||
name = c.Args().First()
|
||||
dry = c.Bool("dry-run")
|
||||
w = c.App.Writer
|
||||
bare = c.Bool("bare")
|
||||
name = cmd.Args().First()
|
||||
dry = cmd.Bool("dry-run")
|
||||
w = cmd.Root().Writer
|
||||
bare = cmd.Bool("bare")
|
||||
)
|
||||
|
||||
if name == "" {
|
||||
|
|
|
|||
|
|
@ -1,22 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func doRoot(c *cli.Context) error {
|
||||
func doRoot(ctx context.Context, cmd *cli.Command) error {
|
||||
roots, err := localRepositoryRoots(true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !c.Bool("all") {
|
||||
if !cmd.Bool("all") {
|
||||
roots = roots[:1] // only the first root is needed
|
||||
}
|
||||
|
||||
for _, root := range roots {
|
||||
_, err := fmt.Fprintln(c.App.Writer, root)
|
||||
_, err := fmt.Fprintln(cmd.Root().Writer, root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
|
@ -90,13 +91,13 @@ func TestDoRoot(t *testing.T) {
|
|||
homeOnce = &sync.Once{}
|
||||
tc.setup(t)
|
||||
out, _, _ := capture(func() {
|
||||
newApp().Run([]string{"", "root"})
|
||||
newApp().Run(context.Background(), []string{"", "root"})
|
||||
})
|
||||
if !samePaths(out, tc.expect) {
|
||||
t.Errorf("got: %s, expect: %s", out, tc.expect)
|
||||
}
|
||||
out, _, _ = capture(func() {
|
||||
newApp().Run([]string{"", "root", "--all"})
|
||||
newApp().Run(context.Background(), []string{"", "root", "--all"})
|
||||
})
|
||||
if !samePaths(out, tc.allExpect) {
|
||||
t.Errorf("got: %s, expect: %s", out, tc.allExpect)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
var commands = []*cli.Command{
|
||||
|
|
@ -43,7 +44,7 @@ var commandGet = &cli.Command{
|
|||
&cli.StringFlag{
|
||||
Name: "partial",
|
||||
Usage: "Do a partial clone. Can specify either \"blobless\" or \"treeless\"",
|
||||
Action: func(ctx *cli.Context, v string) error {
|
||||
Action: func(ctx context.Context, cmd *cli.Command, v string) error {
|
||||
expected := []string{"blobless", "treeless"}
|
||||
if !slices.Contains(expected, v) {
|
||||
return fmt.Errorf("flag partial value \"%v\" is not allowed", v)
|
||||
|
|
|
|||
5
go.mod
5
go.mod
|
|
@ -8,7 +8,7 @@ require (
|
|||
github.com/motemen/go-colorine v0.0.0-20180816141035-45d19169413a
|
||||
github.com/otiai10/copy v1.14.1
|
||||
github.com/saracen/walker v0.1.4
|
||||
github.com/urfave/cli/v2 v2.27.7
|
||||
github.com/urfave/cli/v3 v3.7.0
|
||||
golang.org/x/net v0.52.0
|
||||
golang.org/x/sync v0.20.0
|
||||
)
|
||||
|
|
@ -21,11 +21,8 @@ require (
|
|||
|
||||
require (
|
||||
github.com/cli/safeexec v1.0.1 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
|
||||
github.com/daviddengcn/go-colortext v1.0.0 // indirect
|
||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
|
||||
golang.org/x/sys v0.42.0 // indirect
|
||||
golang.org/x/text v0.35.0
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
|
|
|||
14
go.sum
14
go.sum
|
|
@ -4,8 +4,6 @@ github.com/cli/go-gh/v2 v2.13.0 h1:jEHZu/VPVoIJkciK3pzZd3rbT8J90swsK5Ui4ewH1ys=
|
|||
github.com/cli/go-gh/v2 v2.13.0/go.mod h1:Us/NbQ8VNM0fdaILgoXSz6PKkV5PWaEzkJdc9vR2geM=
|
||||
github.com/cli/safeexec v1.0.1 h1:e/C79PbXF4yYTN/wauC4tviMxEV13BwljGj0N9j+N00=
|
||||
github.com/cli/safeexec v1.0.1/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
|
@ -32,16 +30,12 @@ github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs=
|
|||
github.com/otiai10/mint v1.6.3/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/saracen/walker v0.1.4 h1:/WCOt98GRkQ0KgL6hXJFBpoH21XY6iCD2N6LQWBFiaU=
|
||||
github.com/saracen/walker v0.1.4/go.mod h1:2F+hfOidTHfXP2AmlKOqpO+yewf8fIvNUDBNJogpJbk=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
|
||||
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
|
||||
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg=
|
||||
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/urfave/cli/v3 v3.7.0 h1:AGSnbUyjtLiM+WJUb4dzXKldl/gL+F8OwmRDtVr6g2U=
|
||||
github.com/urfave/cli/v3 v3.7.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
|
||||
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
|
||||
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
|
|
|
|||
27
main.go
27
main.go
|
|
@ -1,10 +1,11 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
"github.com/x-motemen/ghq/logger"
|
||||
)
|
||||
|
||||
|
|
@ -13,7 +14,7 @@ const version = "1.9.4"
|
|||
var revision = "HEAD"
|
||||
|
||||
func main() {
|
||||
if err := newApp().Run(os.Args); err != nil {
|
||||
if err := newApp().Run(context.Background(), os.Args); err != nil {
|
||||
exitCode := 1
|
||||
if excoder, ok := err.(cli.ExitCoder); ok {
|
||||
exitCode = excoder.ExitCode()
|
||||
|
|
@ -23,18 +24,12 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func newApp() *cli.App {
|
||||
app := cli.NewApp()
|
||||
app.Name = "ghq"
|
||||
app.Usage = "Manage remote repository clones"
|
||||
app.Version = fmt.Sprintf("%s (rev:%s)", version, revision)
|
||||
app.Authors = []*cli.Author{{
|
||||
Name: "motemen",
|
||||
Email: "motemen@gmail.com",
|
||||
}, {
|
||||
Name: "Songmu",
|
||||
Email: "y.songmu@gmail.com",
|
||||
}}
|
||||
app.Commands = commands
|
||||
return app
|
||||
func newApp() *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "ghq",
|
||||
Usage: "Manage remote repository clones",
|
||||
Version: fmt.Sprintf("%s (rev:%s)", version, revision),
|
||||
Authors: []any{"motemen <motemen@gmail.com>", "Songmu <y.songmu@gmail.com>"},
|
||||
Commands: commands,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue