Skip to content
This repository was archived by the owner on Feb 11, 2021. It is now read-only.

Commit e07ddc3

Browse files
committed
implement
1 parent f5ff113 commit e07ddc3

File tree

7 files changed

+110
-0
lines changed

7 files changed

+110
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@
2727
*.exe
2828
*.out
2929
*.app
30+
31+
## node
32+
node_modules/

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# CLI template for C/C++
2+
3+
This is template app for CLI test.
4+
You can make console application by editing files under src directory.
5+
As default, app.cpp has `main` function. You can start to develop from here.
6+
7+
## How to get input parameters
8+
Same as ususal C++ application, `main` function takes following parameters.
9+
app.py has a function `main`
10+
11+
- int argc: The number of parameters. (including program name.)
12+
- char *argv[]: The array of char pointer.
13+
14+
## How to output result
15+
You can use `cout`, `printf`, etc.
16+
17+
``` c++
18+
cout << argv[0] << endl
19+
```
20+
21+
## How to compile
22+
To compile, we are using [clang](http://clang.llvm.org/) c++ command.
23+
24+
If you want to change compile option or etc, please edit [codecheck.yml](codecheck.yml) `build` section.
25+
(If you change output filename, you have to change env/APP_COMMAND section too.)
26+
27+
You can build pure C application by switching compiler command from `c++` to `clang`.

README_ja.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# CLIアプリケーション作成用テンプレート(C/C++)
2+
3+
C/C++でCLIアプリケーションを作成するためのテンプレートです。
4+
5+
srcフォルダ以下の*.cppファイルを編集することでCLIアプリケーションを作成することができます。
6+
デフォルトでは[app.cpp](src/app.cpp)ファイルにmain関数が定義されているのでそこから開発を開始してください。
7+
8+
## コマンドライン引数の取得方法
9+
通常のC++アプリケーションと同じです。
10+
main関数の引数として
11+
12+
- int argc: 引数の総数(プログラム名を含む)
13+
- char *argv[]: 引数の文字列を指すポインタの配列
14+
15+
が渡されます。
16+
17+
## コマンド実行結果の標準出力への出力
18+
cout、printf等標準出力に出力する任意のメソッドが使用可能です。
19+
20+
``` c++
21+
cout << argv[0] << endl
22+
```
23+
24+
## コンパイルについて
25+
コンパイルには[clang](http://clang.llvm.org/)のc++コマンドを使用しています。
26+
27+
コンパイルオプション等を変更する場合は[codecheck.yml](codecheck.yml)のbuildセクションを変更してください。
28+
29+
(出力ファイル名を変更した場合はenv/APP_COMMANDセクションも変更が必要です。)
30+
31+
buildをc++からclangに変更することで、(C++ではない)純粋Cアプリケーションも作成可能です。
32+

cli-template.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build:
2+
- c++ -o myapp.o src/app.cpp
3+
files:
4+
- .gitignore
5+
- src/app.cpp
6+
command: ./myapp.o

codecheck.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build:
2+
- c++ -o myapp.o src/app.cpp
3+
env:
4+
APP_COMMAND: ./myapp.o
5+
test: mocha

package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "codecheck-cli-template",
3+
"version": "1.0.0",
4+
"description": "",
5+
"scripts": {
6+
"test": "codecheck"
7+
},
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/code-check/cli-template-cpp.git"
11+
},
12+
"keywords": [
13+
"codecheck",
14+
"cli",
15+
"c++"
16+
],
17+
"author": "Givery Inc.",
18+
"license": "ISC",
19+
"bugs": {
20+
"url": "https://github.com/code-check/cli-template-cpp/issues"
21+
},
22+
"homepage": "https://github.com/code-check/cli-template-cpp#README.md",
23+
"devDependencies": {
24+
"chai": "^3.5.0",
25+
"codecheck": "^0.5.3"
26+
}
27+
}

src/app.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main(int argc, char *argv[])
5+
{
6+
for (int i=1; i<argc; i++) {
7+
cout << argv[i] << endl;
8+
}
9+
return 0;
10+
}

0 commit comments

Comments
 (0)