Skip to content

Commit 182ec81

Browse files
* GitHub Actions;
* `interface{}` => `any`; * boilerplate; * documentation;
1 parent 67ed7a0 commit 182ec81

File tree

12 files changed

+216
-21
lines changed

12 files changed

+216
-21
lines changed

.github/workflows/go.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: Go
5+
6+
on:
7+
push:
8+
branches: [ "master" ]
9+
pull_request:
10+
branches: [ "master" ]
11+
12+
jobs:
13+
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v4
21+
with:
22+
go-version: '1.24'
23+
24+
- name: Build
25+
run: ./build.sh
26+
27+
- name: Test
28+
run: ./run_all_unit_tests.sh

.gitignore

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1-
21
# directories (by name)
32

4-
.DS_Store
3+
/scratch/
4+
55

66
# directories (by pattern)
77

8+
89
# files (by name)
910

11+
.DS_Store
12+
13+
1014
# files (by pattern)
1115

1216
*~
13-
*.swp
17+
*.[568vq]
18+
*.a
19+
*.dylib
20+
*.exe
21+
*.lib
22+
*.o
23+
*.out
24+
*.prof
25+
*.so
26+
*.sw[pon]
27+
*.test
1428
*.tmp
29+
*.zip
1530

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# **CLASP.Go** Changes <!-- omit in toc -->
22

33

4+
## 0.17.1-beta1 - 27th March 2025
5+
6+
* GitHub Actions;
7+
* `interface{}` => `any`;
8+
* boilerplate;
9+
* documentation;
10+
11+
412
## 0.17.0 - 27th March 2025
513

614
* 0.17.0;

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CLASP.Go <!-- omit in toc -->
22

3+
[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
4+
[![GitHub release](https://img.shields.io/github/v/release/synesissoftware/CLASP.Go.svg)](https://github.com/synesissoftware/CLASP.Go/releases/latest)
5+
[![Last Commit](https://img.shields.io/github/last-commit/synesissoftware/CLASP.Go)](https://github.com/synesissoftware/CLASP.Go/commits/master)
6+
[![Go](https://github.com/synesissoftware/CLASP.Go/actions/workflows/go.yml/badge.svg)](https://github.com/synesissoftware/CLASP.Go/actions/workflows/go.yml)
7+
[![Go Report Card](https://goreportcard.com/badge/github.com/synesissoftware/CLASP.Go)](https://goreportcard.com/report/github.com/synesissoftware/CLASP.Go)
38
[![Go Reference](https://pkg.go.dev/badge/github.com/synesissoftware/CLASP.Go.svg)](https://pkg.go.dev/github.com/synesissoftware/CLASP.Go)
49

510
**C**ommand-**L**ine **A**rgument **S**orting and **P**arsing for Go
@@ -27,6 +32,7 @@ Go version.
2732
- [Related projects](#related-projects)
2833
- [License](#license)
2934

35+
3036
## Installation
3137

3238
Install via `go get`, as in:

api.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type Specification struct {
6868
ValueSet []string
6969
BitFlags int
7070
BitFlags64 int64
71-
Extras map[string]interface{}
71+
Extras map[string]any
7272

7373
flags_receiver *int
7474
flags64_receiver *int64
@@ -292,11 +292,11 @@ func (specification Specification) SetAliases(aliases ...string) Specification {
292292
}
293293

294294
// Builder method to set an Extras entry.
295-
func (specification Specification) SetExtra(key string, value interface{}) Specification {
295+
func (specification Specification) SetExtra(key string, value any) Specification {
296296

297297
if specification.Extras == nil {
298298

299-
specification.Extras = make(map[string]interface{})
299+
specification.Extras = make(map[string]any)
300300
}
301301

302302
specification.Extras[key] = value
@@ -707,7 +707,7 @@ func (args Arguments) AllBit64Flags() int64 {
707707
// [Specification] - was observed during parsing.
708708
//
709709
// If an argument is found, then it is marked used.
710-
func (args *Arguments) FlagIsSpecified(id interface{}) bool {
710+
func (args *Arguments) FlagIsSpecified(id any) bool {
711711

712712
name := ""
713713
found := false
@@ -759,7 +759,7 @@ func (args *Arguments) FlagIsSpecified(id interface{}) bool {
759759
// [Specification] - in the parsed arguments.
760760
//
761761
// If an argument is found, then it is marked used.
762-
func (args *Arguments) LookupFlag(id interface{}) (*Argument, bool) {
762+
func (args *Arguments) LookupFlag(id any) (*Argument, bool) {
763763

764764
name := ""
765765
found := false
@@ -807,7 +807,7 @@ func (args *Arguments) LookupFlag(id interface{}) (*Argument, bool) {
807807
// [Specification] - in the parsed arguments.
808808
//
809809
// If an argument is found, then it is marked used.
810-
func (args *Arguments) LookupOption(id interface{}) (*Argument, bool) {
810+
func (args *Arguments) LookupOption(id any) (*Argument, bool) {
811811

812812
name := ""
813813
found := false

build.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#! /bin/bash
2+
3+
ScriptPath=$0
4+
Dir=$(cd $(dirname "$ScriptPath"); pwd)
5+
6+
7+
mkdir -p "$Dir/scratch/build-artefacts/"
8+
9+
10+
# library
11+
echo "building library ..."
12+
go build -v $Dir
13+
14+
# examples
15+
if [ -d "$Dir/examples" ];then
16+
17+
echo "building examples ..."
18+
cd "$Dir/scratch/build-artefacts/"
19+
find "$Dir/examples" -type f -name '*.go' -print -exec go build -v {} \;
20+
cd ->/dev/null
21+
fi
22+
23+
24+
# tests
25+
if [ -d "$Dir/tests" ];then
26+
27+
echo "building tests ..."
28+
cd "$Dir/scratch/build-artefacts/"
29+
find "$Dir/tests" -type f -name '*.go' -print -exec go build -v {} \;
30+
cd ->/dev/null
31+
fi
32+
33+
34+
# ############################## end of file ############################# #
35+

parse_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func equalInNonNillLhs(lhs clasp.Argument, rhs clasp.Argument) bool {
5151
}
5252

5353
/*
54-
func require(t *testing.T, cond bool, format string, args ...interface{}) {
54+
func require(t *testing.T, cond bool, format string, args ...any) {
5555
5656
if !cond {
5757
@@ -70,7 +70,7 @@ func require(t *testing.T, cond bool, format string, args ...interface{}) {
7070
}
7171
*/
7272

73-
func check(t *testing.T, cond bool, format string, args ...interface{}) bool {
73+
func check(t *testing.T, cond bool, format string, args ...any) bool {
7474

7575
if !cond {
7676

run_all_unit_tests.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#! /bin/bash
2+
3+
ScriptPath=$0
4+
Dir=$(cd $(dirname "$ScriptPath"); pwd)
5+
6+
7+
ListOnly=0
8+
Verbosity=${XTESTS_VERBOSITY:-${TEST_VERBOSITY:-3}}
9+
10+
11+
# ##########################################################
12+
# command-line handling
13+
14+
while [[ $# -gt 0 ]]; do
15+
16+
case $1 in
17+
-l|--list-only)
18+
19+
ListOnly=1
20+
;;
21+
--verbosity)
22+
23+
shift
24+
Verbosity=$1
25+
;;
26+
--help)
27+
28+
cat << EOF
29+
ANGoLS provides Algorithms Not in the Go Language Standard library
30+
Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems
31+
Runs all (matching) component and unit test programs
32+
33+
$ScriptPath [ ... flags/options ... ]
34+
35+
Flags/options:
36+
37+
behaviour:
38+
39+
-l
40+
--list-only
41+
lists the target programs but does not execute them
42+
43+
--verbosity <verbosity>
44+
specifies an explicit verbosity for the unit-test(s)
45+
46+
47+
standard flags:
48+
49+
--help
50+
displays this help and terminates
51+
52+
EOF
53+
54+
exit 0
55+
;;
56+
*)
57+
58+
>&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage"
59+
60+
exit 1
61+
;;
62+
esac
63+
64+
shift
65+
done
66+
67+
68+
# ##########################################################
69+
# main()
70+
71+
72+
for f in $(find $Dir -type f -name '*_test.go')
73+
do
74+
75+
if [ $ListOnly -ne 0 ]; then
76+
77+
echo "would execute $f:"
78+
79+
continue
80+
fi
81+
82+
if [ $Verbosity -ge 3 ]; then
83+
84+
echo
85+
fi
86+
if [ $Verbosity -ge 2 ]; then
87+
88+
echo "executing $f:"
89+
fi
90+
91+
if [ $Verbosity -ge 2 ]; then
92+
93+
go test -v "$f"
94+
else
95+
96+
go test "$f"
97+
fi
98+
99+
done
100+
101+
102+
# ############################## end of file ############################# #
103+

usage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type UsageParams struct {
3838
UsageFlags UsageFlag
3939
ExitCode int
4040
Exiter Exiter
41-
Version interface{}
41+
Version any
4242
VersionPrefix string
4343
InfoLines []string
4444
ValuesString string
@@ -99,7 +99,7 @@ func should_call_Exit(params UsageParams) bool {
9999
return true
100100
}
101101

102-
func collect_array_as_strings(a []interface{}) []string {
102+
func collect_array_as_strings(a []any) []string {
103103

104104
r := make([]string, len(a))
105105

usage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func call_ShowUsage_(t *testing.T, specifications []clasp.Specification, ups cla
9393
return
9494
}
9595

96-
func test_ShowVersion_(t *testing.T, expected string, specifications []clasp.Specification, program_name string, version interface{}, version_prefix string) {
96+
func test_ShowVersion_(t *testing.T, expected string, specifications []clasp.Specification, program_name string, version any, version_prefix string) {
9797

9898
t.Helper()
9999

0 commit comments

Comments
 (0)