Skip to content

Commit b8aed98

Browse files
author
R. S. Doiel
committed
prep for v1.3.5, Added urlencode, urldecode and reldocpath cli.
1 parent effbad2 commit b8aed98

45 files changed

Lines changed: 311 additions & 111 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ maintainers:
1515
orcid: ""
1616

1717
repository-code: "https://github.com/caltechlibrary/datatools"
18-
version: 1.3.4
18+
version: 1.3.5
1919
license-url: "https://data.caltech.edu/license"
2020
keywords: [ "csv", "excel", "sql", "json", "yaml", "xlsx", "golang", "bash" ]
21-
date-released: 2025-05-15
21+
date-released: 2026-02-12

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ RELEASE_DATE=$(shell date +'%Y-%m-%d')
99

1010
RELEASE_HASH=$(shell git log --pretty=format:'%h' -n 1)
1111

12-
PROGRAMS = codemeta2cff csv2json csv2jsonl csv2mdtable csv2tab csv2xlsx csvcleaner csvcols csvfind csvjoin csvrows finddir findfile json2toml json2yaml jsoncols jsonjoin jsonmunge jsonrange jsonobjects2csv json2jsonl mergepath range reldate reltime sql2csv string tab2csv timefmt toml2json urlparse xlsx2csv xlsx2json yaml2json
12+
PROGRAMS = codemeta2cff csv2json csv2jsonl csv2mdtable csv2tab csv2xlsx csvcleaner csvcols csvfind csvjoin csvrows finddir findfile json2toml json2yaml jsoncols jsonjoin jsonmunge jsonrange jsonobjects2csv json2jsonl mergepath range reldate reltime sql2csv string tab2csv timefmt toml2json urlparse xlsx2csv xlsx2json yaml2json urldecode urlencode reldocpath
1313

14-
MAN_PAGES = codemeta2cff.1 csv2json.1 csv2jsonl.1 csv2mdtable.1 csv2tab.1 csv2xlsx.1 csvcleaner.1 csvcols.1 csvfind.1 csvjoin.1 csvrows.1 finddir.1 findfile.1 json2toml.1 json2yaml.1 jsoncols.1 jsonjoin.1 jsonmunge.1 jsonrange.1 jsonobjects2csv.1 json2jsonl.1 mergepath.1 range.1 reldate.1 reltime.1 sql2csv.1 string.1 tab2csv.1 timefmt.1 toml2json.1 urlparse.1 xlsx2csv.1 xlsx2json.1 yaml2json.1
14+
MAN_PAGES = codemeta2cff.1 csv2json.1 csv2jsonl.1 csv2mdtable.1 csv2tab.1 csv2xlsx.1 csvcleaner.1 csvcols.1 csvfind.1 csvjoin.1 csvrows.1 finddir.1 findfile.1 json2toml.1 json2yaml.1 jsoncols.1 jsonjoin.1 jsonmunge.1 jsonrange.1 jsonobjects2csv.1 json2jsonl.1 mergepath.1 range.1 reldate.1 reltime.1 sql2csv.1 string.1 tab2csv.1 timefmt.1 toml2json.1 urlparse.1 xlsx2csv.1 xlsx2json.1 yaml2json.1 urldecode.1 urlencode.1 reldocpath.1
1515

1616
PACKAGE = $(shell ls -1 *.go)
1717

about.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ authors:
1111
orcid: ""
1212

1313
repository-code: "https://github.com/caltechlibrary/datatools"
14-
version: 1.3.4
14+
version: 1.3.5
1515
license-url: "https://data.caltech.edu/license"
1616
keywords: [ "csv", "excel", "sql", "json", "yaml", "xlsx", "golang", "bash" ]
17-
date-released: 2025-05-15
17+
date-released: 2026-02-12
1818
---
1919

2020
About this software
2121
===================
2222

23-
## datatools 1.3.4
23+
## datatools 1.3.5
2424

2525
### Authors
2626

cmd/urldecode/urldecode.go

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
//
2+
// urldecode.go is a simple command line utility to decode a string in a URL friendly way.
3+
//
4+
// @author R. S. Doiel, <rsdoiel@caltech.edu>
5+
//
6+
// Copyright (c) 2021, Caltech
7+
// All rights not granted herein are expressly reserved by Caltech.
8+
//
9+
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
10+
//
11+
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
12+
//
13+
// 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.
14+
//
15+
// 3. 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.
16+
//
17+
// 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.
18+
//
19+
package main
20+
21+
import (
22+
"flag"
23+
"fmt"
24+
"io/ioutil"
25+
"net/url"
26+
"os"
27+
"path"
28+
"strings"
29+
30+
// CaltechLibrary Packages
31+
"github.com/caltechlibrary/datatools"
32+
)
33+
34+
var (
35+
helpText = `%{app_name}(1) user manual | version {version} {release_hash}
36+
% R. S. Doiel
37+
% {release_date}
38+
39+
# NAME
40+
41+
{app_name}
42+
43+
# SYNOPSIS
44+
45+
{app_name} [OPTIONS] [URL_ENCODED_STRING]
46+
47+
# DESCRIPTION
48+
49+
{app_name} is a simple command line utility to URL decode content. By default
50+
it reads from standard input and writes to standard out. You can
51+
also specifty the string to decode as a command line parameter.
52+
53+
You can provide the URL encoded string as a command line parameter or if none
54+
present it will be read from standard input.
55+
56+
# OPTIONS
57+
58+
-help
59+
: display help
60+
61+
-license
62+
: display license
63+
64+
-version
65+
: display version
66+
67+
-query
68+
: use query escape (pluses for spaces)
69+
70+
-newline
71+
: Append a trailing newline
72+
73+
# EXAMPLE
74+
75+
echo 'This%20is%20the%20string%20to%20encode%20&%20nothing%20else%0A' | {app_name}
76+
77+
would yield (without the double quotes)
78+
79+
"This is the string to encode & nothing else!"
80+
81+
`
82+
83+
// Standard Options
84+
showHelp bool
85+
showLicense bool
86+
showVersion bool
87+
88+
// App Options
89+
useQueryUnescape bool
90+
newLine bool
91+
)
92+
93+
func main() {
94+
appName := path.Base(os.Args[0])
95+
version := datatools.Version
96+
license := datatools.LicenseText
97+
releaseDate := datatools.ReleaseDate
98+
releaseHash := datatools.ReleaseHash
99+
100+
// Standard Options
101+
flag.BoolVar(&showHelp, "help", showHelp, "display help")
102+
flag.BoolVar(&showLicense, "license", showLicense, "display license")
103+
flag.BoolVar(&showVersion, "version", showVersion, "display version")
104+
flag.BoolVar(&newLine, "newline", false, "append a newline character")
105+
flag.BoolVar(&useQueryUnescape, "query", false, "use query escape (pluses for spaces)")
106+
107+
// Parse environment and options
108+
flag.Parse()
109+
args := flag.Args()
110+
111+
// Setup IO
112+
var err error
113+
114+
in := os.Stdin
115+
out := os.Stdout
116+
eout := os.Stderr
117+
118+
// Handle the default options
119+
if showHelp {
120+
fmt.Fprintf(out, "%s\n", datatools.FmtHelp(helpText, appName, version, releaseDate, releaseHash))
121+
os.Exit(0)
122+
}
123+
if showLicense == true {
124+
fmt.Fprintf(out, "%s\n", license)
125+
os.Exit(0)
126+
}
127+
if showVersion == true {
128+
fmt.Fprintf(out, "datatools, %s %s %s\n", appName, version, releaseHash)
129+
os.Exit(0)
130+
}
131+
132+
nl := "\n"
133+
if newLine == false {
134+
nl = ""
135+
}
136+
137+
var (
138+
src string
139+
s string
140+
)
141+
142+
if len(args) > 0 {
143+
src = strings.Join(args, " ")
144+
} else {
145+
buf, err := ioutil.ReadAll(in)
146+
if err != nil {
147+
fmt.Fprintf(eout, "%s\n", err)
148+
os.Exit(1)
149+
}
150+
src = fmt.Sprintf("%s", buf)
151+
}
152+
if useQueryUnescape {
153+
s, err = url.QueryUnescape(src)
154+
} else {
155+
s, err = url.PathUnescape(src)
156+
}
157+
if err != nil {
158+
fmt.Fprintf(eout, "%s\n", err)
159+
os.Exit(1)
160+
}
161+
fmt.Fprintf(out, "%s%s", s, nl)
162+
}

codemeta.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
}
3030
],
3131
"dateCreated": "2017-02-06",
32-
"dateModified": "2025-05-15",
33-
"datePublished": "2025-05-15",
32+
"dateModified": "2026-02-12",
33+
"datePublished": "2026-02-12",
3434
"description": "A set of command line tools for working with CSV, Excel Workbooks, JSON and structured text documents.",
3535
"funder": {
3636
"@id": "https://ror.org/5dxps055",
@@ -61,9 +61,9 @@
6161
"Golang >= 1.23.5",
6262
"Pandoc >= 3.1"
6363
],
64-
"version": "1.3.4",
64+
"version": "1.3.5",
6565
"developmentStatus": "active",
6666
"issueTracker": "https://github.com/caltechlibrary/datatools/issues",
6767
"downloadUrl": "https://github.com/caltechlibrary/datatools/releases/",
68-
"releaseNotes": "Added json2jsonl. It will render a JSON array document as JSON lines. A `-as-dataset` option is included. If\nan top level attribute name is provided and matches the object it will render the result as a dataset load\ncomponatible object. Of the top level attribute name is not found then that object is skipped with a message\nwritten to standard error."
68+
"releaseNotes": "Added urlencode, urldecode and reldocpath cli."
6969
}

codemeta2cff.1.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
%codemeta2cff(1) user manual | version 1.3.4 4312aaa
1+
%codemeta2cff(1) user manual | version 1.3.5 effbad2
22
% R. S. Doiel
3-
% 2025-05-15
3+
% 2026-02-12
44

55
# NAME
66

csv2json.1.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
%csv2json(1) user manual | version 1.3.4 4312aaa
1+
%csv2json(1) user manual | version 1.3.5 effbad2
22
% R. S. Doiel
3-
% 2025-05-15
3+
% 2026-02-12
44

55
# NAME
66

csv2jsonl.1.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
%csv2jsonl(1) user manual | version 1.3.4 4312aaa
1+
%csv2jsonl(1) user manual | version 1.3.5 effbad2
22
% R. S. Doiel
3-
% 2025-05-15
3+
% 2026-02-12
44

55
# NAME
66

csv2mdtable.1.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
%csv2mdtable(1) user manual | version 1.3.4 4312aaa
1+
%csv2mdtable(1) user manual | version 1.3.5 effbad2
22
% R. S. Doiel
3-
% 2025-05-15
3+
% 2026-02-12
44

55
# NAME
66

@@ -62,6 +62,6 @@ Convert data1.csv to data1.md using options.
6262
csv2mdtable -i data1.csv -o data1.md
6363
~~~
6464

65-
csv2mdtable 1.3.4
65+
csv2mdtable 1.3.5
6666

6767

csv2tab.1.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
%csv2tab(1) user manual | version 1.3.4 4312aaa
1+
%csv2tab(1) user manual | version 1.3.5 effbad2
22
% R. S. Doiel
3-
% 2025-05-15
3+
% 2026-02-12
44

55
# NAME
66

@@ -49,6 +49,6 @@ This would yield
4949
Doe, Jane jane.doe@example.org 42
5050
~~~
5151

52-
csv2tab 1.3.4
52+
csv2tab 1.3.5
5353

5454

0 commit comments

Comments
 (0)