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
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,30 @@ A tool to report CLI arguments.
```
cl clireport.c
clireport.exe A B
clireport.exe --exit 1 A B
```

## Linux

```
docker run --rm -v "$(pwd):/clireport" -w /clireport gcc:latest gcc -o clireport clireport.c
docker run --rm -v "$(pwd):/clireport" -w /clireport ubuntu:latest /clireport/clireport A B
docker run --rm -v "$(pwd):/clireport" -w /clireport ubuntu:latest bash -c '/clireport/clireport A B; echo $?'
docker run --rm -v "$(pwd):/clireport" -w /clireport ubuntu:latest bash -c '/clireport/clireport --exit 1 A B; echo $?'
```

## Docker

```
docker build --tag=ghcr.io/g2forge/clireport:latest .
docker run ghcr.io/g2forge/clireport:latest A B
docker run ghcr.io/g2forge/clireport:latest --exit 1 A B
docker push ghcr.io/g2forge/clireport:latest
```
```

# Release

1. Update [pom.xml](pom.xml) to remove `-SNAPSHOT`, and commit.
2. Update [pom.xml](pom.xml) to update version and re-add `-SNAPSHOT`, and commit.
3. Open a PR
4. Create github release and upload pre-built binaries, tagging the commit created in step 1.
5. Update `HCLIReport` to use the new release, and to match any changes to the command line argument handling or expected output
18 changes: 16 additions & 2 deletions clireport.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>

int main(int argc, char* argv[])
{
int main(int argc, char* argv[]) {
printf("CLIReport: %d arguments\n", argc);
for (int i = 0; i < argc; i++) {
char* argument = argv[i];
printf("%04d: %s\n", (unsigned)strlen(argument), argument);
}

if ((strncmp(argv[1], "--exit", 7) == 0) && (argc >= 3)) {
char *endptr = NULL;
errno = 0;
int exitCode = (int) strtol(argv[2], &endptr, 10);

if ((errno != 0) || *endptr) {
printf ("Exit code \"%s\" is not valid\n", argv[2]);
}

return exitCode;
}

return 0;
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.g2forge.clireport</groupId>
<artifactId>clireport</artifactId>
<packaging>pom</packaging>
<version>0.0.2-SNAPSHOT</version>
<version>0.0.2</version>

<properties>
<clireport.organization>g2forge</clireport.organization>
Expand Down