hancock

Check-in [62d0ed9c79]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:cmd/hancock: command helper, parse args with help mode support
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 62d0ed9c7985bf50092fac4acd32deaaef9f94aee9d5fb7d6044cad4e6742b8b
User & Date: dnc 2020-01-03 17:28:33
Context
2020-01-04
16:12
cmd/hancock: client of http testimony store server side is implemented by hancockd check-in: ceb5b81ccf user: dnc tags: trunk
2020-01-03
17:28
cmd/hancock: command helper, parse args with help mode support check-in: 62d0ed9c79 user: dnc tags: trunk
17:27
cmd/hancock: no longer publishing via ipfs check-in: d2f81cb81e user: dnc tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to cmd/hancock/manifest.go.

1
2
3
4
5
6
7
8
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// COPYRIGHT(C) 2019  David N. Cohen

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
................................................................................
	deprecatedFlag := command.OperationFlagSet.Bool("deprecated", false, "indicate that source is not endorsed because deprecated")
	bugFlag := command.OperationFlagSet.Bool("bug", false, "indicate that source is not endorsed because of known bug")
	vulnFlag := command.OperationFlagSet.Bool("vulnerable", false, "indicate that source is not endorsed because of known vulnerability")

	var messageFlag command.StringSet
	command.OperationFlagSet.Var(&messageFlag, "message", "optional rationale for testimony")

	err := command.OperationFlagSet.Parse(command.Args()[1:])
	if err != nil {
		return err
	}

	// validate flags
	var role model.Role
	if *roleFlag != "" {
|







 







|







1
2
3
4
5
6
7
8
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// COPYRIGHT(C) 2019, 2020  David N. Cohen

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
................................................................................
	deprecatedFlag := command.OperationFlagSet.Bool("deprecated", false, "indicate that source is not endorsed because deprecated")
	bugFlag := command.OperationFlagSet.Bool("bug", false, "indicate that source is not endorsed because of known bug")
	vulnFlag := command.OperationFlagSet.Bool("vulnerable", false, "indicate that source is not endorsed because of known vulnerability")

	var messageFlag command.StringSet
	command.OperationFlagSet.Var(&messageFlag, "message", "optional rationale for testimony")

	err := command.ParseOperationFlagSet()
	if err != nil {
		return err
	}

	// validate flags
	var role model.Role
	if *roleFlag != "" {

Changes to cmd/hancock/testimony.go.

1
2
3
4
5
6
7
8
...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright (C) 2019  David N. Cohen

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
................................................................................
	defaultStore := cfgTestimony.Key("store").MustString(cfgTop.Key("store").String())

	// define args
	storeFlag := command.OperationFlagSet.String("store", defaultStore, "URL where testimony is saved/published")
	noopFlag := command.OperationFlagSet.Bool("n", false, "do not save/publish")

	// parse args
	err = command.OperationFlagSet.Parse(command.Args()[1:])
	if err != nil {
		return err
	}

	// validate args
	remote, err := storeFromFlag(*storeFlag)
	if err != nil {
|







 







|







1
2
3
4
5
6
7
8
...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright (C) 2019, 2020  David N. Cohen

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
................................................................................
	defaultStore := cfgTestimony.Key("store").MustString(cfgTop.Key("store").String())

	// define args
	storeFlag := command.OperationFlagSet.String("store", defaultStore, "URL where testimony is saved/published")
	noopFlag := command.OperationFlagSet.Bool("n", false, "do not save/publish")

	// parse args
	err = command.ParseOperationFlagSet()
	if err != nil {
		return err
	}

	// validate args
	remote, err := storeFromFlag(*storeFlag)
	if err != nil {

Changes to cmd/hancock/verify.go.

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

	defaultStore := cfg.Section("").Key("store").MustString("http://localhost:3344")

	strictFlag := command.OperationFlagSet.Bool("strict", false, "strict mode requires source to be endorsed")
	command.OperationFlagSet.Var(&verifyStoreFlag, "store", fmt.Sprintf("URL of testimony store (default %s)", defaultStore))
	recurseFlag := command.OperationFlagSet.Bool("r", false, "verify all files in directory")

	err = command.OperationFlagSet.Parse(command.Args()[1:])
	if err != nil {
		return err
	}
	if len(verifyStoreFlag) == 0 && len(defaultStore) > 0 {
		verifyStoreFlag = append(verifyStoreFlag, strings.Split(defaultStore, ",")...) // comma separated list allowed in config file
	}
	if len(verifyStoreFlag) == 0 {







|







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

	defaultStore := cfg.Section("").Key("store").MustString("http://localhost:3344")

	strictFlag := command.OperationFlagSet.Bool("strict", false, "strict mode requires source to be endorsed")
	command.OperationFlagSet.Var(&verifyStoreFlag, "store", fmt.Sprintf("URL of testimony store (default %s)", defaultStore))
	recurseFlag := command.OperationFlagSet.Bool("r", false, "verify all files in directory")

	err = command.ParseOperationFlagSet()
	if err != nil {
		return err
	}
	if len(verifyStoreFlag) == 0 && len(defaultStore) > 0 {
		verifyStoreFlag = append(verifyStoreFlag, strings.Split(defaultStore, ",")...) // comma separated list allowed in config file
	}
	if len(verifyStoreFlag) == 0 {