Commit 57457af7 authored by Kevin Atkinson's avatar Kevin Atkinson

Change --output-cidv1 to --force-cid-base.

License: MIT
Signed-off-by: default avatarKevin Atkinson <k@kevina.org>
parent 8209ba61
......@@ -10,7 +10,7 @@ import (
)
var OptionCidBase = cmdkit.StringOption("cid-base", "Multibase encoding used for version 1 CIDs in output.")
var OptionOutputCidV1 = cmdkit.BoolOption("output-cidv1", "Upgrade CID version 0 to version 1 in output.")
var OptionForceCidBase = cmdkit.BoolOption("force-cid-base", "Force multibase prefix by upgrading CIDv0 to CIDv1.")
// GetCidEncoder processes the `cid-base` and `output-cidv1` options and
// returns a encoder to use based on those parameters.
......@@ -26,8 +26,8 @@ func GetLowLevelCidEncoder(req *cmds.Request) (cidenc.Encoder, error) {
}
func getCidBase(req *cmds.Request, autoUpgrade bool) (cidenc.Encoder, error) {
base, _ := req.Options["cid-base"].(string)
upgrade, upgradeDefined := req.Options["output-cidv1"].(bool)
base, _ := req.Options[OptionCidBase.Name()].(string)
upgrade, upgradeDefined := req.Options[OptionForceCidBase.Name()].(bool)
e := cidenc.Default()
......
......@@ -100,7 +100,7 @@ The CLI will exit with one of the following values:
// global options, added to every command
cmdenv.OptionCidBase,
cmdenv.OptionOutputCidV1,
cmdenv.OptionForceCidBase,
cmds.OptionEncodingType,
cmds.OptionStreamChannels,
......
......@@ -363,11 +363,11 @@ test_object_cmd() {
test_cmp expected_putOut actual_putOut
'
test_expect_success "'ipfs object put file.json --cid-base=base32 --output-cidv1=true' succeeds" '
ipfs object put --cid-base=base32 --output-cidv1=true ../t0051-object-data/testPut.json > actual_putOut
test_expect_success "'ipfs object put file.json --cid-base=base32 --force-cid-base=true' succeeds" '
ipfs object put --cid-base=base32 --force-cid-base=true ../t0051-object-data/testPut.json > actual_putOut
'
test_expect_success "'ipfs object put file.json --cid-base=base32 --output-cidv1=true' output looks good" '
test_expect_success "'ipfs object put file.json --cid-base=base32 --force-cid-base=true' output looks good" '
HASH=$(ipfs cid base32 "QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD") &&
printf "added $HASH\n" > expected_putOut &&
test_cmp expected_putOut actual_putOut
......@@ -394,8 +394,8 @@ test_object_cmd() {
grep -q $(ipfs cid base32 $HASHv1) mixed.actual
'
test_expect_success "ipfs object links --cid-base=base32 --output-cidv1=true converts both links" '
ipfs object links --cid-base=base32 --output-cidv1=true $MIXED | awk "{print \$1}" | sort > links.actual &&
test_expect_success "ipfs object links --cid-base=base32 --force-cid-base=true converts both links" '
ipfs object links --cid-base=base32 --force-cid-base=true $MIXED | awk "{print \$1}" | sort > links.actual &&
echo $(ipfs cid base32 $HASHv1) > links.expected
echo $(ipfs cid base32 $HASHv0) >> links.expected
test_cmp links.actual links.expected
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment