Skip to content

Commit 7180dc1

Browse files
committed
Update CI, help text and README
1 parent 205d39f commit 7180dc1

3 files changed

Lines changed: 37 additions & 31 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
cmake --version
4646
ls
4747
cd target
48-
echo ./cppgen CppProject --test --cmake -v
49-
./cppgen CppProject --test --cmake -v
48+
echo ./cppgen CppProject --test --cmake -V
49+
./cppgen CppProject --test --cmake -V
5050
if: runner.os != 'Windows'
5151

5252
- name: Run binary file Windows
@@ -56,8 +56,8 @@ jobs:
5656
cmake --version
5757
ls
5858
cd target
59-
echo ./cppgen.exe CppProject --test -v
60-
./cppgen.exe CppProject --test -v
59+
echo ./cppgen.exe CppProject --test -V
60+
./cppgen.exe CppProject --test -V
6161
if: runner.os == 'Windows'
6262

6363
- name: Set C++/C compiler on macOS

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
# cpp-generator-cli [![CI build](https://github.com/mwthinker/cpp-generator-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/mwthinker/cpp-generator-cli/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/mwthinker/cpp-generator-cli/graph/badge.svg?token=T6CE5XBPEQ)](https://codecov.io/gh/mwthinker/cpp-generator-cli) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2-
A java application based on JDK 21 and maven. Implements a C++ generator CLI.
2+
A java application based on JDK 25 and maven. Implements a C++ generator CLI.
33

44
## How to use
5-
Generates a C++ project template based on cmake and vcpkg.
5+
Generates a C++ project template based on cmake and vcpkg.
66

77
Usage of the generated binary file:
88
```bash
99
cppgen --help
1010
Script to generate a CMake C++ project
1111

12-
Usage: cppgen [-cghotvV] [-d=DESCRIPTION] [-l=LICENSE] -n=NEW
13-
C++ generator
14-
-c, --cmake run cmake
12+
Usage: cppgen [-cghkotvV] [-d=DESCRIPTION] [-l=LICENSE] [PROJECT_NAME]
13+
C++ generator using CMake
14+
[PROJECT_NAME] The project name.
15+
-c, --cmake Run cmake.
1516
-d, --description=DESCRIPTION
16-
short description used in the template
17-
-g, --gui add gui library
18-
-h, --help display a help message
19-
-l, --license=LICENSE add MIT license with author
20-
-n, --new=NEW the project name
21-
-o, --open open visual studio solution
22-
-t, --test add test
23-
-V, --version display version info
24-
-v, --verbose show verbose output
17+
Short description set in CMakeLists.txt.
18+
-g, --gui Add gui library.
19+
-h, --help Display this help message.
20+
-k, --keepFiles Keep generated files on error.
21+
-l, --license=LICENSE Add MIT license with author.
22+
-o, --open Open visual studio solution.
23+
-t, --test Add test.
24+
-v, --version Display version info.
25+
-V, --verbose Show verbose output.
2526
```
2627

2728
Example of generating a C++ project and open in Visual Studio C++ 2022:
2829
```bash
2930
cppgen.exe --new NewProject -o
3031
```
3132

32-
A Visual Studio C++ 2022 solution should be opened and ready to be used. Assumes that vcpkg is installed and environment variable VCPKG_ROOT pointing to it. Visual Studio 2022 and CMake 3.24 must also be installed and available in the PATH environment variable.
33+
A Visual Studio C++ 2022 solution should be opened and ready to be used. Assumes that vcpkg is installed and environment variable VCPKG_ROOT pointing to it. Visual Studio 2022 and CMake >=3.24v must also be installed and available in the PATH environment variable.
3334

3435
## License
3536
MIT

src/main/java/se/mwthinker/GeneratorCli.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package se.mwthinker;
22

3+
import org.apache.commons.lang3.SystemUtils;
34
import org.jline.consoleui.elements.ConfirmChoice;
45
import org.jline.consoleui.prompt.ConsolePrompt;
56
import org.jline.consoleui.prompt.PromptResultItemIF;
@@ -19,7 +20,6 @@
1920

2021
@SuppressWarnings({"SpellCheckingInspection", "java:S106"})
2122
@Command(name = "cppgen",
22-
mixinStandardHelpOptions = true,
2323
description = "C++ generator using CMake"
2424
)
2525
public class GeneratorCli implements Closeable, Flushable {
@@ -53,6 +53,9 @@ public class GeneratorCli implements Closeable, Flushable {
5353
@Option(names = { "-v", "--version" }, versionHelp = true, description = "Display version info.")
5454
private boolean versionRequested = false;
5555

56+
@Option(names = { "-h", "--help" }, usageHelp = true, description = "Display this help message.")
57+
private boolean help = false;
58+
5659
private Terminal terminal;
5760

5861
static void main(String[] args) {
@@ -85,13 +88,11 @@ public void run(String[] args) {
8588
try {
8689
commandLine.parseArgs(args);
8790
} catch (CommandLine.ParameterException e) {
88-
builder.createText()
89-
.addLine("Argument error: " + e.getMessage())
90-
.addPrompt();
91+
System.err.println("Argument error: " + e.getMessage());
9192
System.exit(2);
9293
}
9394

94-
if (commandLine.isUsageHelpRequested()) {
95+
if (help) {
9596
commandLine.usage(System.out);
9697
System.exit(0);
9798
} else if (versionRequested) {
@@ -138,13 +139,17 @@ private void interactivePrompt(ConsolePrompt prompt, PromptBuilder builder) {
138139
.name("cmake")
139140
.message("Run cmake after generation?")
140141
.defaultValue(ConfirmChoice.ConfirmationValue.NO)
141-
.addPrompt()
142-
.createConfirmPromp()
143-
.name("open")
144-
.message("Open Visual Studio solution?")
145-
.defaultValue(ConfirmChoice.ConfirmationValue.NO)
146-
.addPrompt()
147-
.createConfirmPromp()
142+
.addPrompt();
143+
144+
if (SystemUtils.IS_OS_WINDOWS) {
145+
builder.createConfirmPromp()
146+
.name("open")
147+
.message("Open Visual Studio solution?")
148+
.defaultValue(ConfirmChoice.ConfirmationValue.NO)
149+
.addPrompt();
150+
}
151+
152+
builder.createConfirmPromp()
148153
.name("verbose")
149154
.message("Show verbose output?")
150155
.defaultValue(ConfirmChoice.ConfirmationValue.NO)

0 commit comments

Comments
 (0)