Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,29 @@ on:
paths:
- '**.c'
- '**.h'
- 'build.sh'
- '**.tspec'
- '.github/workflows/main.yml'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: ./build.sh && ./out/tests
- uses: actions/checkout@v4

- name: Build strum
run: |
git clone --depth 1 https://github.com/Strongleong/Strum strum
cd strum
cc build.c -o build
./build -c gcc
echo "$PWD/out" >> "$GITHUB_PATH"

- name: Build
run: |
cc build.c -o build
./build

- name: Test
run: ./build tests
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.cache
compile_commands.json
out
**/.side_effects/
out/
build
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@

## Upcoming

### Added

- `OPTLY_NULL_FLAG`, `OPTLY_NULL_COMMAND` and `OPTLY_NULL_POSITIONAL`.
The old spellings still work, but they are deprecated and will be
removed in v3.
- `optly_flag_value_enum()` is declared in the header. It has always been
there, but only code that defined `OPTLY_IMPLEMENTATION` could reach it.
- A test suite in the .tspec format, run with strum. 43 tests across 11
directories, covering flag forms, every value type, commands and
subcommands, positionals, error accumulation, enums, usage output and the
exit behaviour.

### Fixed

- **A crash reachable from any optly program's command line.** A flag written
as `--name=value` where the name is longer than `OPTLY_FLAG_BUFFER_LENGTH`
(256) was truncated before its `=`, and the split then wrote through a NULL
pointer. Such a flag is now reported as unknown.
- `OPTLY_HELP_SHORT_FLAG` and `OPTLY_VERSION_SHORT_FLAG` were honoured when
parsing but ignored when printing usage, so overriding them left a program
advertising flags it did not accept.
- `optly_get_positional()` was declared twice in the header.

### Changed

- `build.sh` is replaced by `build.c`. The script never compiled the examples:
it guarded the compile with a variable it never assigned. Its flag handling
was broken too, and bash ruled out Windows. See the README for usage.

## v2.3.6

### Fixed
Expand Down
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,39 @@ Define these before including optly:
Optly is a C library. It is not tested as C++ and does not try to compile as
C++ -- use argparse, CLI11 or cxxopts there.

## Building

Optly itself is a single header -- there is nothing to build to use it. The
repository ships `build.c`, which compiles the examples and runs the tests.
Compile it once, then use the binary:

``` bash
cc build.c -o build

./build # compile every example into ./out
./build tests # run the .tspec suite
./build clean # empty the output directory
```

Run `./build help` for more info.

## Tests

Tests live in `./tests/`, one directory per concept. Each holds a small C
fixture and a `test.tspec` that compiles it, runs it, and compares the exact
bytes it writes.

They are written in the .tspec format and run with strum:

``` bash
./build tests
```

strum has to be on your `PATH`. Use `--tspec-runner` to point at a different
implementation of the format.

Read more about tspec and strum at [https://github.com/strongleong/strum](https://github.com/strongleong/strum)

## Design Goals

Optly focuses on:
Expand Down
Loading
Loading