diff --git a/Makefile b/Makefile index 1fe408a..6734014 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ VERSION = $(shell grep '"version":' codemeta.json | cut -d \" -f 4) BRANCH = $(shell git branch | grep '* ' | cut -d\ -f 2) -PKGASSETS = $(shell which pkgassets) CODEMETA2CFF = $(shell which codemeta2cff) @@ -32,16 +31,12 @@ version.go: .FORCE crossrefapi$(EXT): bin/crossrefapi$(EXT) -cmd/crossrefapi/assets.go: - pkgassets -o cmd/crossrefapi/assets.go -p main -ext=".md" -strip-prefix="/" -strip-suffix=".md" Examples how-to Help docs/crossrefapi - git add cmd/crossrefapi/assets.go - -bin/crossrefapi$(EXT): crossrefapi.go cmd/crossrefapi/crossrefapi.go cmd/crossrefapi/assets.go - go build -o bin/crossrefapi$(EXT) cmd/crossrefapi/crossrefapi.go cmd/crossrefapi/assets.go +bin/crossrefapi$(EXT): crossrefapi.go cmd/crossrefapi/crossrefapi.go + go build -o bin/crossrefapi$(EXT) cmd/crossrefapi/crossrefapi.go install: - env GOBIN=$(GOPATH)/bin go install cmd/crossrefapi/crossrefapi.go cmd/crossrefapi/assets.go + env GOBIN=$(GOPATH)/bin go install cmd/crossrefapi/crossrefapi.go website: page.tmpl README.md nav.md INSTALL.md LICENSE css/site.css bash mk-website.bash @@ -60,7 +55,6 @@ lint: golint cmd/crossrefapi/crossrefapi.go clean: - if [ "$(PKGASSETS)" != "" ]; then bash rebuild-assets.bash; fi if [ -f index.html ]; then rm *.html; fi if [ -d bin ]; then rm -fR bin; fi if [ -d dist ]; then rm -fR dist; fi @@ -73,31 +67,31 @@ man: build dist/linux-amd64: mkdir -p dist/bin - env GOOS=linux GOARCH=amd64 go build -o dist/bin/crossrefapi cmd/crossrefapi/crossrefapi.go cmd/crossrefapi/assets.go + env GOOS=linux GOARCH=amd64 go build -o dist/bin/crossrefapi cmd/crossrefapi/crossrefapi.go cd dist && zip -r $(PROJECT)-$(VERSION)-linux-amd64.zip README.md LICENSE INSTALL.md bin/* rm -fR dist/bin dist/windows-amd64: mkdir -p dist/bin - env GOOS=windows GOARCH=amd64 go build -o dist/bin/crossrefapi.exe cmd/crossrefapi/crossrefapi.go cmd/crossrefapi/assets.go + env GOOS=windows GOARCH=amd64 go build -o dist/bin/crossrefapi.exe cmd/crossrefapi/crossrefapi.go cd dist && zip -r $(PROJECT)-$(VERSION)-windows-amd64.zip README.md LICENSE INSTALL.md bin/* rm -fR dist/bin dist/macos-amd64: mkdir -p dist/bin - env GOOS=darwin GOARCH=amd64 go build -o dist/bin/crossrefapi cmd/crossrefapi/crossrefapi.go cmd/crossrefapi/assets.go + env GOOS=darwin GOARCH=amd64 go build -o dist/bin/crossrefapi cmd/crossrefapi/crossrefapi.go cd dist && zip -r $(PROJECT)-$(VERSION)-macos-amd64.zip README.md LICENSE INSTALL.md bin/* rm -fR dist/bin dist/macos-arm64: mkdir -p dist/bin - env GOOS=darwin GOARCH=arm64 go build -o dist/bin/crossrefapi cmd/crossrefapi/crossrefapi.go cmd/crossrefapi/assets.go + env GOOS=darwin GOARCH=arm64 go build -o dist/bin/crossrefapi cmd/crossrefapi/crossrefapi.go cd dist && zip -r $(PROJECT)-$(VERSION)-macos-arm64.zip README.md LICENSE INSTALL.md bin/* rm -fR dist/bin dist/raspbian-arm7: mkdir -p dist/bin - env GOOS=linux GOARCH=arm GOARM=7 go build -o dist/bin/crossrefapi cmd/crossrefapi/crossrefapi.go cmd/crossrefapi/assets.go + env GOOS=linux GOARCH=arm GOARM=7 go build -o dist/bin/crossrefapi cmd/crossrefapi/crossrefapi.go cd dist && zip -r $(PROJECT)-$(VERSION)-raspbian-arm7.zip README.md LICENSE INSTALL.md bin/* rm -fR dist/bin diff --git a/cmd/crossrefapi/assets.go b/cmd/crossrefapi/assets.go deleted file mode 100644 index 2d7bab9..0000000 --- a/cmd/crossrefapi/assets.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -var ( - - // Help is a map to asset files associated with main package - Help = map[string][]byte{ - "index": {0xa,0x55,0x53,0x41,0x47,0x45,0xa,0x3d,0x3d,0x3d,0x3d,0x3d,0xa,0xa,0x9,0x63,0x72,0x6f,0x73,0x73,0x72,0x65,0x66,0x61,0x70,0x69,0x20,0x5b,0x4f,0x50,0x54,0x49,0x4f,0x4e,0x53,0x5d,0x20,0x74,0x79,0x70,0x65,0x73,0x7c,0x77,0x6f,0x72,0x6b,0x73,0x20,0x44,0x4f,0x49,0xa,0xa,0x53,0x59,0x4e,0x4f,0x50,0x53,0x49,0x53,0xa,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0xa,0xa,0xa,0x5f,0x63,0x72,0x6f,0x73,0x73,0x72,0x65,0x66,0x61,0x70,0x69,0x5f,0x20,0x63,0x61,0x6e,0x20,0x72,0x65,0x74,0x72,0x69,0x65,0x76,0x65,0x20,0x22,0x74,0x79,0x70,0x65,0x73,0x22,0x20,0x61,0x6e,0x64,0x20,0x22,0x77,0x6f,0x72,0x6b,0x73,0x22,0x20,0x66,0x72,0x6f,0x6d,0x20,0x74,0x68,0x65,0x20,0x43,0x72,0x6f,0x73,0x73,0x52,0x65,0x66,0x20,0x41,0x50,0x49,0xa,0xa,0xa,0x44,0x45,0x53,0x43,0x52,0x49,0x50,0x54,0x49,0x4f,0x4e,0xa,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0xa,0xa,0xa,0x5f,0x63,0x72,0x6f,0x73,0x73,0x72,0x65,0x66,0x61,0x70,0x69,0x5f,0x20,0x69,0x73,0x20,0x61,0x20,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x20,0x6c,0x69,0x6e,0x65,0x20,0x75,0x74,0x69,0x6c,0x69,0x74,0x79,0x20,0x74,0x6f,0x20,0x72,0x65,0x74,0x72,0x69,0x65,0x76,0x65,0x20,0x22,0x74,0x79,0x70,0x65,0x73,0x22,0x20,0x61,0x6e,0x64,0x20,0x22,0x77,0x6f,0x72,0x6b,0x73,0x22,0x20,0x6f,0x62,0x6a,0x65,0x63,0x74,0x73,0xa,0x66,0x72,0x6f,0x6d,0x20,0x74,0x68,0x65,0x20,0x43,0x72,0x6f,0x73,0x73,0x52,0x65,0x66,0x20,0x41,0x50,0x49,0x2e,0x20,0x49,0x74,0x20,0x66,0x6f,0x6c,0x6c,0x6f,0x77,0x73,0x20,0x74,0x68,0x65,0x20,0x65,0x74,0x69,0x71,0x75,0x65,0x74,0x74,0x65,0x20,0x73,0x75,0x67,0x67,0x65,0x73,0x74,0x65,0x64,0x20,0x61,0x74,0xa,0xa,0x60,0x60,0x60,0xa,0x20,0x20,0x20,0x20,0x68,0x74,0x74,0x70,0x73,0x3a,0x2f,0x2f,0x67,0x69,0x74,0x68,0x75,0x62,0x2e,0x63,0x6f,0x6d,0x2f,0x43,0x72,0x6f,0x73,0x73,0x52,0x65,0x66,0x2f,0x72,0x65,0x73,0x74,0x2d,0x61,0x70,0x69,0x2d,0x64,0x6f,0x63,0x23,0x65,0x74,0x69,0x71,0x75,0x65,0x74,0x74,0x65,0xa,0x60,0x60,0x60,0xa,0xa,0xa,0x4f,0x50,0x54,0x49,0x4f,0x4e,0x53,0xa,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0xa,0xa,0x42,0x65,0x6c,0x6f,0x77,0x20,0x61,0x72,0x65,0x20,0x61,0x20,0x73,0x65,0x74,0x20,0x6f,0x66,0x20,0x6f,0x70,0x74,0x69,0x6f,0x6e,0x73,0x20,0x61,0x76,0x61,0x69,0x6c,0x61,0x62,0x6c,0x65,0x2e,0xa,0xa,0x60,0x60,0x60,0xa,0x20,0x20,0x20,0x20,0x2d,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x2d,0x6d,0x61,0x6e,0x70,0x61,0x67,0x65,0x20,0x20,0x20,0x20,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x20,0x6d,0x61,0x6e,0x20,0x70,0x61,0x67,0x65,0xa,0x20,0x20,0x20,0x20,0x2d,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x2d,0x6d,0x61,0x72,0x6b,0x64,0x6f,0x77,0x6e,0x20,0x20,0x20,0x6f,0x75,0x74,0x70,0x75,0x74,0x20,0x64,0x6f,0x63,0x75,0x6d,0x65,0x6e,0x74,0x61,0x74,0x69,0x6f,0x6e,0x20,0x69,0x6e,0x20,0x4d,0x61,0x72,0x6b,0x64,0x6f,0x77,0x6e,0xa,0x20,0x20,0x20,0x20,0x2d,0x68,0x2c,0x20,0x2d,0x68,0x65,0x6c,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x70,0x6c,0x61,0x79,0x20,0x68,0x65,0x6c,0x70,0xa,0x20,0x20,0x20,0x20,0x2d,0x6c,0x2c,0x20,0x2d,0x6c,0x69,0x63,0x65,0x6e,0x73,0x65,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x70,0x6c,0x61,0x79,0x20,0x6c,0x69,0x63,0x65,0x6e,0x73,0x65,0xa,0x20,0x20,0x20,0x20,0x2d,0x6d,0x2c,0x20,0x2d,0x6d,0x61,0x69,0x6c,0x74,0x6f,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x73,0x65,0x74,0x20,0x74,0x68,0x65,0x20,0x6d,0x61,0x69,0x6c,0x74,0x6f,0x20,0x76,0x61,0x6c,0x75,0x65,0x20,0x66,0x6f,0x72,0x20,0x41,0x50,0x49,0x20,0x61,0x63,0x63,0x65,0x73,0x73,0xa,0x20,0x20,0x20,0x20,0x2d,0x76,0x2c,0x20,0x2d,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x70,0x6c,0x61,0x79,0x20,0x61,0x70,0x70,0x20,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0xa,0x60,0x60,0x60,0xa,0xa,0xa,0x45,0x58,0x41,0x4d,0x50,0x4c,0x45,0x53,0xa,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0xa,0xa,0xa,0x52,0x65,0x74,0x75,0x72,0x6e,0x20,0x74,0x68,0x65,0x20,0x74,0x79,0x70,0x65,0x73,0x20,0x6f,0x66,0x20,0x6f,0x62,0x6a,0x65,0x63,0x74,0x73,0x20,0x69,0x6e,0x20,0x43,0x72,0x6f,0x73,0x73,0x52,0x65,0x66,0x20,0x28,0x65,0x2e,0x67,0x2e,0x20,0x6a,0x6f,0x75,0x72,0x6e,0x61,0x6c,0x20,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x29,0xa,0xa,0x60,0x60,0x60,0xa,0x20,0x20,0x20,0x20,0x63,0x72,0x6f,0x73,0x73,0x72,0x65,0x66,0x61,0x70,0x69,0x20,0x2d,0x6d,0x61,0x69,0x6c,0x74,0x6f,0x3d,0x22,0x6a,0x64,0x6f,0x65,0x40,0x65,0x78,0x61,0x6d,0x70,0x6c,0x65,0x2e,0x65,0x64,0x75,0x22,0x20,0x74,0x79,0x70,0x65,0x73,0xa,0x60,0x60,0x60,0xa,0xa,0x52,0x65,0x74,0x75,0x72,0x6e,0x20,0x74,0x68,0x65,0x20,0x77,0x6f,0x72,0x6b,0x73,0x20,0x66,0x6f,0x72,0x20,0x74,0x68,0x65,0x20,0x64,0x6f,0x69,0x20,0x22,0x31,0x30,0x2e,0x31,0x30,0x33,0x37,0x2f,0x30,0x30,0x30,0x33,0x2d,0x30,0x36,0x36,0x78,0x2e,0x35,0x39,0x2e,0x31,0x2e,0x32,0x39,0x22,0xa,0xa,0x60,0x60,0x60,0xa,0x20,0x20,0x20,0x20,0x63,0x72,0x6f,0x73,0x73,0x72,0x65,0x66,0x61,0x70,0x69,0x20,0x2d,0x6d,0x61,0x69,0x6c,0x74,0x6f,0x3d,0x22,0x6a,0x64,0x6f,0x65,0x40,0x65,0x78,0x61,0x6d,0x70,0x6c,0x65,0x2e,0x65,0x64,0x75,0x22,0x20,0x5c,0xa,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x77,0x6f,0x72,0x6b,0x73,0x20,0x22,0x31,0x30,0x2e,0x31,0x30,0x33,0x37,0x2f,0x30,0x30,0x30,0x33,0x2d,0x30,0x36,0x36,0x78,0x2e,0x35,0x39,0x2e,0x31,0x2e,0x32,0x39,0x22,0xa,0x60,0x60,0x60,0xa,0xa,0xa,0x63,0x72,0x6f,0x73,0x73,0x72,0x65,0x66,0x61,0x70,0x69,0x20,0x76,0x30,0x2e,0x30,0x2e,0x35,0xa}, - - } - -) - diff --git a/cmd/crossrefapi/crossrefapi.go b/cmd/crossrefapi/crossrefapi.go index 10677fc..9781287 100644 --- a/cmd/crossrefapi/crossrefapi.go +++ b/cmd/crossrefapi/crossrefapi.go @@ -21,45 +21,47 @@ package main import ( "encoding/json" + "flag" "fmt" "os" "path" "strings" // Caltech Library packages - "github.com/caltechlibrary/cli" "github.com/caltechlibrary/crossrefapi" ) var ( - synopsis = ` -_%s_ can retrieve "types" and "works" from the CrossRef API -` description = ` -_%s_ is a command line utility to retrieve "types" and "works" objects +USAGE + + {appName} [OPTIONS] DOI + +SYNOPSIS + +{appName} can retrieve "types" and "works" from the CrossRef API + +DETAIL + +{appName} is a command line utility to retrieve "types" and "works" objects from the CrossRef API. It follows the etiquette suggested at -` + "```" + ` https://github.com/CrossRef/rest-api-doc#etiquette -` + "```" + ` + ` examples = ` Return the types of objects in CrossRef (e.g. journal articles) -` + "```" + ` - %s -mailto="jdoe@example.edu" types -` + "```" + ` + {appName} -mailto="jdoe@example.edu" types Return the works for the doi "10.1037/0003-066x.59.1.29" -` + "```" + ` - %s -mailto="jdoe@example.edu" \ + {appName} -mailto="jdoe@example.edu" \ works "10.1037/0003-066x.59.1.29" -` + "```" + ` ` license = ` -%s %s +{appName} {version} Copyright (c) 2021, Caltech All rights not granted herein are expressly reserved by Caltech. @@ -75,8 +77,6 @@ Redistribution and use in source and binary forms, with or without modification, 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. ` // Standard Options - generateMarkdown bool - generateManPage bool showHelp bool showLicense bool showVersion bool @@ -106,62 +106,40 @@ func pop(args []string) (string, []string) { func main() { appName := path.Base(os.Args[0]) - app := cli.NewCli(crossrefapi.Version) - app.SetParams("types|works DOI") - - app.AddHelp("synopsis", []byte(fmt.Sprintf(synopsis, appName))) - app.AddHelp("description", []byte(fmt.Sprintf(description, appName))) - app.AddHelp("examples", []byte(fmt.Sprintf(examples, appName, appName))) - app.AddHelp("license", []byte(fmt.Sprintf(license, appName, crossrefapi.Version))) - for k, v := range Help { - app.AddHelp(k, v) - } + flagSet := flag.NewFlagSet(appName, flag.ContinueOnError) + // Standard Options - app.BoolVar(&showHelp, "h,help", false, "display help") - app.BoolVar(&showLicense, "l,license", false, "display license") - app.BoolVar(&showVersion, "v,version", false, "display app version") - app.BoolVar(&generateMarkdown, "generate-markdown", false, "output documentation in Markdown") - app.BoolVar(&generateManPage, "generate-manpage", false, "generate man page") + flagSet.BoolVar(&showHelp, "h", false, "display help") + flagSet.BoolVar(&showHelp, "h,help", false, "display help") + flagSet.BoolVar(&showLicense, "license", false, "display license") + flagSet.BoolVar(&showVersion, "version", false, "display app version") // Application Options - app.StringVar(&mailto, "m,mailto", "", "set the mailto value for API access") + flagSet.StringVar(&mailto, "m", "", "set the mailto value for API access") + flagSet.StringVar(&mailto, "m,mailto", "", "set the mailto value for API access") - app.Parse() - args := app.Args() + flagSet.Parse(os.Args) + args := flagSet.Args() - if generateMarkdown { - app.GenerateMarkdown(os.Stdout) - os.Exit(0) - } - if generateManPage { - app.GenerateManPage(os.Stdout) - os.Exit(0) - } if showHelp { - if showHelp { - if len(args) > 0 { - fmt.Fprintf(os.Stdout, app.Help(args...)) - } else { - app.Usage(os.Stdout) - } - os.Exit(0) - } + crossrefapi.DisplayUsage(os.Stdout, appName, flagSet, description, examples, license) + os.Exit(0) } if showLicense { - fmt.Fprintln(os.Stdout, app.License()) + crossrefapi.DisplayLicense(os.Stdout, appName, license) os.Exit(0) } if showVersion { - fmt.Fprintln(os.Stdout, app.Version()) + crossrefapi.DisplayVersion(os.Stdout, appName) os.Exit(0) } if len(args) < 1 { - app.Usage(os.Stderr) + crossrefapi.DisplayUsage(os.Stderr, appName, flagSet, description, examples, license) os.Exit(1) } diff --git a/crossrefapiCli.go b/crossrefapiCli.go new file mode 100644 index 0000000..2505e44 --- /dev/null +++ b/crossrefapiCli.go @@ -0,0 +1,34 @@ +package crossrefapi + +import ( + "flag" + "fmt" + "io" + "strings" +) + +func DisplayLicense(out io.Writer, appName string, license string) { + fmt.Fprintf(out, strings.ReplaceAll(strings.ReplaceAll(license, "{appName}", appName), "{version}", Version)) +} + +func DisplayVersion(out io.Writer, appName string) { + fmt.Fprintf(out, "\n%s %s\n", appName, Version) +} + +func DisplayUsage(out io.Writer, appName string, flagSet *flag.FlagSet, description string, examples string, license string) { + // Convert {appName} and {version} in description + if description != "" { + fmt.Fprintf(out, strings.ReplaceAll(description, "{appName}", appName)) + } + flagSet.SetOutput(out) + flagSet.PrintDefaults() + + if examples != "" { + fmt.Fprintf(out, strings.ReplaceAll(examples, "{appName}", appName)) + } + if license != "" { + DisplayLicense(out, appName, license) + } + DisplayVersion(out, appName) +} + diff --git a/gen-usage-pages.bash b/gen-usage-pages.bash deleted file mode 100755 index 5f9f41f..0000000 --- a/gen-usage-pages.bash +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [[ ! -f bin/dataset ]]; then - echo "Running make before generating updated docs." - make -fi -bin/dataset -generate-markdown >"docs/dataset.md" - -for TOPIC in "attach" "attachments" "check" "clone" "clone-sample" "count" "create" "deindexer" "delete" "delete-frame" "detach" "export-csv" "export-gsheet" "find" "frame" "frame-labels" "frame-types" "frames" "grid" "haskey" "import-csv" "import-gsheet" "indexer" "init" "join" "keys" "list" "path" "prune" "read" "reframe" "repair" "status" "update"; do - bin/dataset -help "${TOPIC}" >"docs/${TOPIC}.md" -done diff --git a/go.mod b/go.mod index 075cd22..6c8a8a3 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,4 @@ module github.com/caltechlibrary/crossrefapi go 1.17 -require ( - github.com/caltechlibrary/cli v0.0.18 - github.com/caltechlibrary/doitools v0.0.0-20190910184449-c524f84bb2b3 -) +require github.com/caltechlibrary/doitools v0.0.0-20190910184449-c524f84bb2b3 diff --git a/go.sum b/go.sum index db46bd6..04e86e4 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,2 @@ -github.com/caltechlibrary/cli v0.0.18 h1:Z1NjhJ2ar2lWCFlA00wVDa5j0qnsL2XeI/qtgX2wOXU= -github.com/caltechlibrary/cli v0.0.18/go.mod h1:9crFPycCNeyTWautZ0t/YjaW8Clsr9uQZfq/SNNwhak= github.com/caltechlibrary/doitools v0.0.0-20190910184449-c524f84bb2b3 h1:CPVAtgb3KfFDvN/LA6lk3JGT76tVC+PohQWynTkS52s= github.com/caltechlibrary/doitools v0.0.0-20190910184449-c524f84bb2b3/go.mod h1:dBtDM+sEd5W27XSuPTcYGUNmkO9PWJ4JMh5bW1EO8L0= diff --git a/index.html b/index.html deleted file mode 100644 index 8eec076..0000000 --- a/index.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Caltech Library's Digital Library Development Sandbox - - - -
-Caltech Library logo -
- - -
-

-crossrefapi -

-

-This is a go package for working with the CrossRef API. It is inspired by the an excellent CrossRefAPI Python package listed in the CrossRef API docs. This package is meant to follow the “polite” guidelines for interacting with the public API at api.crossref.org. -

-

-Go package example -

-
-
    client, err := crossrefapi.NewCrossRefClient("jane.doe@library.example.edu")
-    if err != nil {
-        // handle error...
-    }
-    works, err := client.Works("10.1037/0003-066x.59.1.29")
-   
-    if err != nil {
-        // handle error...
-    }
-    // continue processing your "works" result...
-
-

-Command line example -

-
    crossrefapi -mailto="jane.doe@library.example.edu" works "10.1037/0003-066x.59.1.29"
-

-Reference -

- -
- - - - diff --git a/install.html b/install.html deleted file mode 100644 index c24eba3..0000000 --- a/install.html +++ /dev/null @@ -1,290 +0,0 @@ - - - - Caltech Library's Digital Library Development Sandbox - - - -
-Caltech Library logo -
- - -
-

-Installation -

-

-crossrefapi is a command line program run from a shell like Bash. It allows you to retrieve JSON works and types object from the CrossRefAPI in a polite manner. -

-

-This is generalized instructions for a release. For deployment suggestions see NOTES.md -

-

-Compiled version -

-

-Compiled versions are available for Mac OS X (amd64 and M1 processor, macos-amd64, macos-arm64), Linux (amd64 process, linux-amd64), Windows (amd64 processor, windows-amd64) and Rapsberry Pi (arm7 processor, raspbian-arm7) -

-

-VERSION_NUMBER is a symantic version number (e.g. v0.1.2) -

-

-For all the released version go to the project page on Github and click latest release -

-
-

-https://github.com/caltechlibrary/crossrefapi/releases/latest -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Platform - -Zip Filename -
-Windows - -crossrefapi-VERSION_NUMBER-windows-amd64.zip -
-Mac OS X - -crossrefapi-VERSION_NUMBER-macos-amd64.zip -
-Mac OS X - -crossrefapi-VERSION_NUMBER-macos-arm64.zip -
-Linux/Intel - -crossrefapi-VERSION_NUMBER-linux-amd64.zip -
-Raspbery Pi - -crossrefapi-VERSION_NUMBER-raspbian-arm7.zip -
-

-The basic recipe -

- -

-Mac OS X -

-
    -
  1. -Download the zip file -
  2. -
  3. -Unzip the zip file -
  4. -
  5. -Copy the executables to $HOME/bin (or a folder in your path) -
  6. -
  7. -Make sure the new location in in our path -
  8. -
  9. -Test -
  10. -
-

-Here’s an example of the commands run in the Terminal App after downloading the zip file. -

-
    cd Downloads/
-    unzip crossrefapi-*-macos-amd64.zip
-    mkdir -p $HOME/bin
-    cp -v bin/* $HOME/bin/
-    export PATH=$HOME/bin:$PATH
-    crossrefapi -version
-

-Windows -

-
    -
  1. -Download the zip file -
  2. -
  3. -Unzip the zip file -
  4. -
  5. -Copy the executables to $HOME/bin (or a folder in your path) -
  6. -
  7. -Test -
  8. -
-

-Here’s an example of the commands run in from the Bash shell on Windows 10 after downloading the zip file. -

-
    cd Downloads/
-    unzip crossrefapi-*-windows-amd64.zip
-    mkdir -p $HOME/bin
-    cp -v bin/* $HOME/bin/
-    export PATH=$HOME/bin:$PATH
-    crossrefapi -version
-

-Linux -

-
    -
  1. -Download the zip file -
  2. -
  3. -Unzip the zip file -
  4. -
  5. -Copy the executables to $HOME/bin (or a folder in your path) -
  6. -
  7. -Test -
  8. -
-

-Here’s an example of the commands run in from the Bash shell after downloading the zip file. -

-
    cd Downloads/
-    unzip crossrefapi-*-linux-amd64.zip
-    mkdir -p $HOME/bin
-    cp -v bin/* $HOME/bin/
-    export PATH=$HOME/bin:$PATH
-    crossrefapi -version
-

-Raspberry Pi -

-

-Released version is for a Raspberry Pi 2 or later use (i.e. requires ARM 7 support). -

-
    -
  1. -Download the zip file -
  2. -
  3. -Unzip the zip file -
  4. -
  5. -Copy the executables to $HOME/bin (or a folder in your path) -
  6. -
  7. -Test -
  8. -
-

-Here’s an example of the commands run in from the Bash shell after downloading the zip file. -

-
    cd Downloads/
-    unzip crossrefapi-*-raspbian-arm7.zip
-    mkdir -p $HOME/bin
-    cp -v bin/* $HOME/bin/
-    export PATH=$HOME/bin:$PATH
-    crossrefapi -version
-

-Compiling from source -

-

-crossrefapi is “go gettable”. Use the “go get” command to download the dependant packages as well as crossrefapi’s source code. -

-
    go get -u github.com/caltechlibrary/crossrefapi/...
-

-Or clone the repstory and then compile -

-
    cd
-    git clone https://github.com/caltechlibrary/crossrefapi src/github.com/caltechlibrary/crossrefapi
-    cd src/github.com/caltechlibrary/crossrefapi
-    make
-    make test
-    make install
-

-Compilation assumes go v1.16 -

-
- - - - diff --git a/license.html b/license.html deleted file mode 100644 index e119cae..0000000 --- a/license.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - Caltech Library's Digital Library Development Sandbox - - - -
-Caltech Library logo -
- - -
-

-Copyright (c) 2021, Caltech All rights not granted herein are expressly reserved by Caltech. -

-

-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. -
  3. -

    -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. -

    -
  4. -
  5. -

    -Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -

    -
  6. -
-

-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. -

-
- - - - diff --git a/package-versions.bash b/package-versions.bash deleted file mode 100755 index 3ac270f..0000000 --- a/package-versions.bash +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# -# Crawl the included Caltech Library package and display their versions in GOPATH -# -function crawl_code() { - findfile -s ".go" . | while read FNAME; do - grep "${1}" "${FNAME}" | cut -d \" -f 2 | while read PNAME; do - V=$(grep 'Version = `' "${GOPATH}/src/${PNAME}/$(basename "${PNAME}").go" | cut -d \` -f 2) - if [ "$V" != "" ]; then - echo "$PNAME -- $V" - fi - done - done | sort -u -} - -echo "The following package versions were used in this release" -crawl_code "github.com/caltechlibrary/" -crawl_code "github.com/rsdoiel/" diff --git a/update_version.py b/update_version.py deleted file mode 100755 index 8554ea9..0000000 --- a/update_version.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python3 - -# Project values -PROJECT_GO = "crossrefapi.go" -CODEMETA_JSON = "codemeta.json" - -# -# No changes below this line -# -import sys -import os -import json - -def inc_patch_no(v = "0.0.0"): - """inc_patch_no takes a symvar and increments the right most value in the dot touple""" - parts = v.split(".") - if len(parts) == 3: - #major_no = parts[0] - #minor_no = parts[1] - patch_no = int(parts[2]) - patch_no += 1 - parts[2] = str(patch_no) - return ".".join(parts) - else: - return v - -def update_codemeta_json(codemeta_json, current_version, next_version): - with open(codemeta_json, mode = "r", encoding = "utf-8") as f: - src = f.read() - meta = json.loads(src) - meta["version"] = next_version - downloadURL = meta["downloadUrl"] - meta["downloadUrl"] = downloadURL.replace(current_version, next_version) - src = json.dumps(meta, indent = 4) - with open(codemeta_json, mode = "w", encoding = "utf-8") as f: - f.write(src) - print(f"updated {codemeta_json} version from {current_version} to {next_version}") - return True - -def update_project_go(project_go, current_version, next_version): - if current_version.startswith("v"): - old_str = current_version - else: - old_str = f"Version = `v{current_version}`" - if next_version.startswith("v"): - new_str = next_version - else: - new_str = f"Version = `v{next_version}`" - with open(project_go, mode = "r", encoding = "utf-8") as f: - src = f.read() - txt = src.replace(old_str, new_str) - if src == txt: - print("Failed, Something isn't correct could not replace", old_str, "with", new_str) - return False - with open(project_go, mode = "w", encoding = "utf-8") as f: - f.write(txt) - print(f"updated {project_go} Version from v{current_version} to v{next_version}") - return True - -def usage(app_name): - app_name = os.path.basename(app_name) - print(f""" -USAGE: {app_name} OPTIONS - -SYNOPSIS - -{app_name} shows or sets the proposed new value for a version number. -By defaut it proposes a increment in the patch no of a symvar string. -If the -y, --yes option is included it will commit the change in patch -number to the codemeta.json and project's go file. - -OPTIONS - - --set VALUE explicitly set the value of the new version string - -y, --yes commit the changes proposed to the Codemeta and Go file. -""") - -# -# Main processing -# -def main(args): - if ("-h" in args) or ("-help" in args) or ("--help" in args): - usage(args[0]) - sys.exit(0) - current_version = "" - next_version = "" - meta = {} - with open(CODEMETA_JSON,"r") as f: - src = f.read() - meta = json.loads(src) - - current_version = meta["version"] - - if ("--set" in args): - i = args.index("--set") - i += 1 - if len(args) < i: - print("Missing new version number after set", args) - sys.exit(1) - next_version = args[i] - if next_version[0] == "v": - next_version = next_version[1:] - else: - next_version = inc_patch_no(current_version) - - if ("--yes" in args) or ("-yes" in args) or ("-y" in args): - update_codemeta_json(CODEMETA_JSON, current_version, next_version) - update_project_go(PROJECT_GO, current_version, next_version) - else: - print("current version:", current_version) - print("proposed version:", next_version) - -if __name__ == "__main__": - main(sys.argv[:])