Skip to content

Commit

Permalink
refactor: rename --detaild to --names
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jan 4, 2024
1 parent d04ebca commit 88f8a9e
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
20 changes: 10 additions & 10 deletions core/commands/pin/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var addPinCmd = &cmds.Command{
Create a pin for the given object, protecting resolved CID from being garbage
collected.
An optional name can be provided, and read back via 'ipfs pin ls --detailed'.
An optional name can be provided, and read back via 'ipfs pin ls --names'.
Be mindful of defaults:
Expand All @@ -71,7 +71,7 @@ Use 'pin ls -t recursive' to only list roots of recursively pinned DAGs
(significantly faster when many big DAGs are pinned recursively)
Default pin name is empty. Pass '--name' to 'pin add' to set one
and use 'pin ls --detailed' to see it.
and use 'pin ls --names' to see it.
Pin add is idempotent: pinning CID which is already pinned won't change
the name, value passed with '--name' with the original pin is preserved.
To rename pin, use 'pin rm' and 'pin add --name'.
Expand Down Expand Up @@ -302,10 +302,10 @@ ipfs pin ls -t indirect <cid>
}

const (
pinTypeOptionName = "type"
pinQuietOptionName = "quiet"
pinStreamOptionName = "stream"
pinDetailedOptionName = "detailed"
pinTypeOptionName = "type"
pinQuietOptionName = "quiet"
pinStreamOptionName = "stream"
pinNamesOptionName = "names"
)

var listPinCmd = &cmds.Command{
Expand Down Expand Up @@ -333,7 +333,7 @@ Valid values are:
* "all"
By default, pin names are not included (returned as empty).
Pass '--detailed' flag to return pin names (set with '--name' from 'pin add').
Pass '--names' flag to return pin names (set with '--name' from 'pin add').
With arguments, the command fails if any of the arguments is not a pinned
object. And if --type=<type> is additionally used, the command will also fail
Expand Down Expand Up @@ -363,7 +363,7 @@ Example:
cmds.StringOption(pinTypeOptionName, "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\".").WithDefault("all"),
cmds.BoolOption(pinQuietOptionName, "q", "Write just hashes of objects."),
cmds.BoolOption(pinStreamOptionName, "s", "Enable streaming of pins as they are discovered."),
cmds.BoolOption(pinDetailedOptionName, "d", "Enable displaying additional information, such as pin names (slower)."),
cmds.BoolOption(pinNamesOptionName, "n", "Enable displaying pin names (slower)."),
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
api, err := cmdenv.GetApi(env, req)
Expand All @@ -373,7 +373,7 @@ Example:

typeStr, _ := req.Options[pinTypeOptionName].(string)
stream, _ := req.Options[pinStreamOptionName].(bool)
detailed, _ := req.Options[pinDetailedOptionName].(bool)
displayNames, _ := req.Options[pinNamesOptionName].(bool)

Check warning on line 376 in core/commands/pin/pin.go

View check run for this annotation

Codecov / codecov/patch

core/commands/pin/pin.go#L376

Added line #L376 was not covered by tests

switch typeStr {
case "all", "direct", "indirect", "recursive":
Expand All @@ -399,7 +399,7 @@ Example:
if len(req.Arguments) > 0 {
err = pinLsKeys(req, typeStr, api, emit)
} else {
err = pinLsAll(req, typeStr, detailed, api, emit)
err = pinLsAll(req, typeStr, displayNames, api, emit)

Check warning on line 402 in core/commands/pin/pin.go

View check run for this annotation

Codecov / codecov/patch

core/commands/pin/pin.go#L402

Added line #L402 was not covered by tests
}
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion docs/changelogs/v0.26.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Several deprecated commands have been removed:

#### Support optional pin names

You can now add a name to a pin when pinning a CID. To do so, use `ipfs pin add --name "Some Name" bafy...`. You can list your pins, including their names, with `ipfs pin ls --detailed`.
You can now add a name to a pin when pinning a CID. To do so, use `ipfs pin add --name "Some Name" bafy...`. You can list your pins, including their names, with `ipfs pin ls --names`.

### 📝 Changelog

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/kubo-as-a-library/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go 1.20
replace github.com/ipfs/kubo => ./../../..

require (
github.com/ipfs/boxo v0.16.1-0.20240102133734-dc2f8b06ce71
github.com/ipfs/boxo v0.16.1-0.20240104123757-57031e8a329f
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
github.com/libp2p/go-libp2p v0.32.2
github.com/multiformats/go-multiaddr v0.12.0
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/kubo-as-a-library/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
github.com/ipfs/boxo v0.16.1-0.20240102133734-dc2f8b06ce71 h1:4WeZGWkOD4Wr2aGm7xXWdwGgPZbCYHjaz+gVaxx1sJ8=
github.com/ipfs/boxo v0.16.1-0.20240102133734-dc2f8b06ce71/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
github.com/ipfs/boxo v0.16.1-0.20240104123757-57031e8a329f h1:6IJ9sfRKLTtgpH/9e8mlvseju07eszJMrzoYnjRcIdA=
github.com/ipfs/boxo v0.16.1-0.20240104123757-57031e8a329f/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/ipfs-shipyard/nopfs v0.0.12-0.20231027223058-cde3b5ba964c
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c
github.com/ipfs/boxo v0.16.1-0.20240102133734-dc2f8b06ce71
github.com/ipfs/boxo v0.16.1-0.20240104123757-57031e8a329f
github.com/ipfs/go-block-format v0.2.0
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-cidutil v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
github.com/ipfs/boxo v0.16.1-0.20240102133734-dc2f8b06ce71 h1:4WeZGWkOD4Wr2aGm7xXWdwGgPZbCYHjaz+gVaxx1sJ8=
github.com/ipfs/boxo v0.16.1-0.20240102133734-dc2f8b06ce71/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
github.com/ipfs/boxo v0.16.1-0.20240104123757-57031e8a329f h1:6IJ9sfRKLTtgpH/9e8mlvseju07eszJMrzoYnjRcIdA=
github.com/ipfs/boxo v0.16.1-0.20240104123757-57031e8a329f/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ=
Expand Down
8 changes: 4 additions & 4 deletions test/cli/pins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ func TestPins(t *testing.T) {
require.Contains(t, lsOut, outARegular)
require.NotContains(t, lsOut, outADetailed)

lsOut = pinLs("-t=recursive", "--detailed")
lsOut = pinLs("-t=recursive", "--names")
require.Contains(t, lsOut, outADetailed)
require.NotContains(t, lsOut, outARegular)

_ = node.IPFS("pin", "update", cidAStr, cidBStr)
lsOut = pinLs("-t=recursive", "--detailed")
lsOut = pinLs("-t=recursive", "--names")
require.Contains(t, lsOut, outBDetailed)
require.NotContains(t, lsOut, outADetailed)
})
Expand Down Expand Up @@ -265,11 +265,11 @@ func TestPins(t *testing.T) {
require.Contains(t, lsOut, outARegular)
require.NotContains(t, lsOut, outADetailed)

lsOut = pinLs("-t=recursive", "--detailed")
lsOut = pinLs("-t=recursive", "--names")
require.Contains(t, lsOut, outADetailed)

_ = node.IPFS("pin", "update", cidAStr, cidBStr)
lsOut = pinLs("-t=recursive", "--detailed")
lsOut = pinLs("-t=recursive", "--names")
require.Contains(t, lsOut, outBDetailed)
})
}
2 changes: 1 addition & 1 deletion test/dependencies/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ require (
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/boxo v0.16.1-0.20240102133734-dc2f8b06ce71 // indirect
github.com/ipfs/boxo v0.16.1-0.20240104123757-57031e8a329f // indirect
github.com/ipfs/go-block-format v0.2.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions test/dependencies/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
github.com/ipfs/boxo v0.16.1-0.20240102133734-dc2f8b06ce71 h1:4WeZGWkOD4Wr2aGm7xXWdwGgPZbCYHjaz+gVaxx1sJ8=
github.com/ipfs/boxo v0.16.1-0.20240102133734-dc2f8b06ce71/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
github.com/ipfs/boxo v0.16.1-0.20240104123757-57031e8a329f h1:6IJ9sfRKLTtgpH/9e8mlvseju07eszJMrzoYnjRcIdA=
github.com/ipfs/boxo v0.16.1-0.20240104123757-57031e8a329f/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs=
github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM=
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
Expand Down

0 comments on commit 88f8a9e

Please sign in to comment.