From 7a4f3d926f9659dea3ba1b83ec81b72d1178019c Mon Sep 17 00:00:00 2001 From: takayukioda Date: Mon, 24 Oct 2016 22:46:31 +0900 Subject: [PATCH 01/15] update test cases --- cli-template.yml | 2 +- codecheck.yml | 2 +- package.json | 27 +++++++++++++++++++++++++++ test/cases.json | 8 ++++++++ test/test.js | 19 +++++++++++++++++++ 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 package.json create mode 100644 test/cases.json create mode 100644 test/test.js diff --git a/cli-template.yml b/cli-template.yml index bb7c1a8..71d8f9a 100644 --- a/cli-template.yml +++ b/cli-template.yml @@ -1,5 +1,5 @@ build: - - mcs src/*.cs -out:TheApp.exe + - mcs "src/*.cs" -out:TheApp.exe files: - .gitignore - src/App.cs diff --git a/codecheck.yml b/codecheck.yml index 4b89f90..7918463 100644 --- a/codecheck.yml +++ b/codecheck.yml @@ -1,5 +1,5 @@ build: - - mcs src/*.cs -out:TheApp.exe + - mcs "src/*.cs" -out:TheApp.exe env: APP_COMMAND: mono TheApp.exe main: src/App.cs diff --git a/package.json b/package.json new file mode 100644 index 0000000..564e8da --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "codecheck-cli-template", + "version": "1.0.0", + "description": "", + "scripts": { + "test": "codecheck" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/code-check/cli-template-csharp.git" + }, + "keywords": [ + "codecheck", + "cli", + "c++" + ], + "author": "Givery Inc.", + "license": "ISC", + "bugs": { + "url": "https://github.com/code-check/cli-template-csharp/issues" + }, + "homepage": "https://github.com/code-check/cli-template-csharp#README.md", + "devDependencies": { + "chai": "^3.5.0", + "codecheck": "^0.5.3" + } +} diff --git a/test/cases.json b/test/cases.json new file mode 100644 index 0000000..d40d1ae --- /dev/null +++ b/test/cases.json @@ -0,0 +1,8 @@ +[ + { "it": "hoge ->-> hoge", + "input": ["hoge"], "output": ["hoge"]}, + { "it": "hoge, fuga ->-> hoge, fuga", + "input": ["hoge", "fuga"], "output": ["hoge", "fuga"]}, + { "it": "hoge fuga ->-> hoge fuga", + "input": ["hoge fuga"], "output": ["hoge fuga"]} +] diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..8cdb9e5 --- /dev/null +++ b/test/test.js @@ -0,0 +1,19 @@ +"use strict"; + +const assert = require("chai").assert; +const codecheck = require("codecheck"); +const app = codecheck.consoleApp(process.env.APP_COMMAND); + +describe("Echo", function() { + let cases = require("./cases.json"); + cases.forEach(v => { + let desc = v.it || `${v.input.join(", ")} ->-> ${v.output.join(", ")}`; + it(desc, () => { + return app.codecheck(v.input).then(result => { + assert.equal(result.code, 0); + assert.deepEqual(result.stdout, v.output); + }); + }); + }); +}); + From cf4a76d24903c8a290c1fa765f0210b1ba78c833 Mon Sep 17 00:00:00 2001 From: takayukioda Date: Tue, 1 Nov 2016 16:00:14 +0900 Subject: [PATCH 02/15] Update filename abandon to use `Main` as class name; it gives an error because of namespace conflict --- README.md | 4 ++-- README_ja.md | 4 ++-- cli-template.yml | 2 +- codecheck.yml | 2 +- src/{App.cs => MainApp.cs} | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename src/{App.cs => MainApp.cs} (88%) diff --git a/README.md b/README.md index d1a433a..8627c8f 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # Command line application template for C# -Implement CLI application by editing [src/App.cs](src/App.cs) +Implement CLI application by editing [MainApp.cs](src/MainApp.cs) You may add new files to keep your code clean, if it is allowed in your challenge. ## How to get input parameters You can get arguments as `args` parameter, defined in Main method ```cs -public class App +public class MainApp { static public void Main(string[] args) { diff --git a/README_ja.md b/README_ja.md index 3b3d209..87ea584 100644 --- a/README_ja.md +++ b/README_ja.md @@ -1,13 +1,13 @@ # コマンドラインアプリケーション(CLI アプリ)作成用テンプレート(C#) -[src/App.cs](src/App.cs)を編集して、CLIアプリを実装してください。 +[MainApp.cs](src/MainApp.cs)を編集して、CLIアプリを実装してください。 チャレンジ内でファイルの作成が許可されていれば、可読性等のためにファイルを分割する事も可能です。 ## コマンドライン引数の取得方法 Main関数の引数 `args` で配列として取得することができます。 ```cs -public class App +public class MainApp { static public void Main(string[] args) { diff --git a/cli-template.yml b/cli-template.yml index 71d8f9a..078e3c0 100644 --- a/cli-template.yml +++ b/cli-template.yml @@ -2,5 +2,5 @@ build: - mcs "src/*.cs" -out:TheApp.exe files: - .gitignore - - src/App.cs + - src/MainApp.cs command: mono TheApp.exe diff --git a/codecheck.yml b/codecheck.yml index 7918463..af742af 100644 --- a/codecheck.yml +++ b/codecheck.yml @@ -2,5 +2,5 @@ build: - mcs "src/*.cs" -out:TheApp.exe env: APP_COMMAND: mono TheApp.exe -main: src/App.cs +main: src/MainApp.cs test: mocha diff --git a/src/App.cs b/src/MainApp.cs similarity index 88% rename from src/App.cs rename to src/MainApp.cs index 7d47256..1a5fbb2 100644 --- a/src/App.cs +++ b/src/MainApp.cs @@ -1,6 +1,6 @@ using System; -public class App +public class MainApp { static public void Main (string[] args) { From c8866cedfe077bf5f3916abc05458dc4f8899399 Mon Sep 17 00:00:00 2001 From: takayukioda Date: Tue, 1 Nov 2016 16:04:24 +0900 Subject: [PATCH 03/15] update package.json information --- package.json | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/package.json b/package.json index 564e8da..e5beb86 100644 --- a/package.json +++ b/package.json @@ -5,21 +5,12 @@ "scripts": { "test": "codecheck" }, - "repository": { - "type": "git", - "url": "git+https://github.com/code-check/cli-template-csharp.git" - }, "keywords": [ "codecheck", "cli", - "c++" + "c#" ], - "author": "Givery Inc.", "license": "ISC", - "bugs": { - "url": "https://github.com/code-check/cli-template-csharp/issues" - }, - "homepage": "https://github.com/code-check/cli-template-csharp#README.md", "devDependencies": { "chai": "^3.5.0", "codecheck": "^0.5.3" From dc1068c3873092d376a76efcc98eb056cfa2dfe0 Mon Sep 17 00:00:00 2001 From: Takayuki Oda Date: Thu, 22 Dec 2016 11:14:11 +0900 Subject: [PATCH 04/15] Update cli-template.yml --- cli-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli-template.yml b/cli-template.yml index 078e3c0..5936219 100644 --- a/cli-template.yml +++ b/cli-template.yml @@ -1,5 +1,5 @@ build: - - mcs "src/*.cs" -out:TheApp.exe + - mcs src/*.cs -out:TheApp.exe files: - .gitignore - src/MainApp.cs From e5aaf1f20ff863e96335ba642a28a74928881a5f Mon Sep 17 00:00:00 2001 From: Takayuki Oda Date: Thu, 22 Dec 2016 11:14:34 +0900 Subject: [PATCH 05/15] Update codecheck.yml --- codecheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecheck.yml b/codecheck.yml index af742af..4041f08 100644 --- a/codecheck.yml +++ b/codecheck.yml @@ -1,5 +1,5 @@ build: - - mcs "src/*.cs" -out:TheApp.exe + - mcs src/*.cs -out:TheApp.exe env: APP_COMMAND: mono TheApp.exe main: src/MainApp.cs From e92caa7614806112256e3d22a8336842332c940a Mon Sep 17 00:00:00 2001 From: Takayuki Oda Date: Thu, 22 Dec 2016 11:51:05 +0900 Subject: [PATCH 06/15] Update README.md --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 8627c8f..da409ad 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,26 @@ You can use `Console.WriteLine` method to out put your results. ```cs Console.WriteLine("hoge") ``` + +## For local exam using GitHub +To use codecheck command in your local environment, you need to modify [codecheck.yml](./codecheck.yml) in order to run test properly. + +```yaml +# Before +build: + - mcs src/*.cs -out:TheApp.exe +env: + APP_COMMAND: mono TheApp.exe +main: src/MainApp.cs +test: mocha +``` + +```yaml +# After +build: + - mcs "src/*.cs" -out:TheApp.exe +env: + APP_COMMAND: mono TheApp.exe +main: src/MainApp.cs +test: mocha +``` From bc64d7eeb64a99f922173ddcc5a5991a65895bb0 Mon Sep 17 00:00:00 2001 From: Takayuki Oda Date: Thu, 22 Dec 2016 11:55:05 +0900 Subject: [PATCH 07/15] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index da409ad..0696465 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ You can use `Console.WriteLine` method to out put your results. ## For local exam using GitHub To use codecheck command in your local environment, you need to modify [codecheck.yml](./codecheck.yml) in order to run test properly. +Don't forget to **restore the file** at the time of submit! ```yaml # Before From e67952b649ed1f63f812217985d07a9c731caf6a Mon Sep 17 00:00:00 2001 From: Takayuki Oda Date: Thu, 22 Dec 2016 11:56:19 +0900 Subject: [PATCH 08/15] Update README_ja.md --- README_ja.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README_ja.md b/README_ja.md index 87ea584..4fee3ae 100644 --- a/README_ja.md +++ b/README_ja.md @@ -22,3 +22,27 @@ public class MainApp ```cs Console.WriteLine("hoge") ``` + +## GitHub を用いたローカル受験の場合 +codecheck コマンドでテストを行う場合、次のように [codecheck.yml](codecheck.yml) を修正する必要があります。 +(提出時にはもとに戻すことを忘れないでください!) + +```yaml +# Before +build: + - mcs src/*.cs -out:TheApp.exe +env: + APP_COMMAND: mono TheApp.exe +main: src/MainApp.cs +test: mocha +``` + +```yaml +# After +build: + - mcs "src/*.cs" -out:TheApp.exe +env: + APP_COMMAND: mono TheApp.exe +main: src/MainApp.cs +test: mocha +``` From 6cf52a8f91c85c3f31c9d7dbeb38ddd6d347a19d Mon Sep 17 00:00:00 2001 From: Takayuki Oda Date: Thu, 22 Dec 2016 11:56:34 +0900 Subject: [PATCH 09/15] Update README_ja.md --- README_ja.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_ja.md b/README_ja.md index 4fee3ae..6a415db 100644 --- a/README_ja.md +++ b/README_ja.md @@ -24,7 +24,7 @@ public class MainApp ``` ## GitHub を用いたローカル受験の場合 -codecheck コマンドでテストを行う場合、次のように [codecheck.yml](codecheck.yml) を修正する必要があります。 +codecheck コマンドでテストを行う場合、次のように [codecheck.yml](codecheck.yml) を修正する必要があります。 (提出時にはもとに戻すことを忘れないでください!) ```yaml From b1cacb6afc601e74dd4e8178cc3fd41c949ca4b0 Mon Sep 17 00:00:00 2001 From: Takayuki Oda Date: Thu, 22 Dec 2016 11:57:33 +0900 Subject: [PATCH 10/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0696465..0f37c83 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Command line application template for C# +# Command line application template for `C#` Implement CLI application by editing [MainApp.cs](src/MainApp.cs) You may add new files to keep your code clean, if it is allowed in your challenge. From 5927cdbeb67cbdb52d24001daeb11b0682e1553c Mon Sep 17 00:00:00 2001 From: Takayuki Oda Date: Wed, 1 Feb 2017 16:19:11 +0900 Subject: [PATCH 11/15] Update README.md --- README.md | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/README.md b/README.md index 0f37c83..6eb5220 100644 --- a/README.md +++ b/README.md @@ -22,27 +22,3 @@ You can use `Console.WriteLine` method to out put your results. ```cs Console.WriteLine("hoge") ``` - -## For local exam using GitHub -To use codecheck command in your local environment, you need to modify [codecheck.yml](./codecheck.yml) in order to run test properly. -Don't forget to **restore the file** at the time of submit! - -```yaml -# Before -build: - - mcs src/*.cs -out:TheApp.exe -env: - APP_COMMAND: mono TheApp.exe -main: src/MainApp.cs -test: mocha -``` - -```yaml -# After -build: - - mcs "src/*.cs" -out:TheApp.exe -env: - APP_COMMAND: mono TheApp.exe -main: src/MainApp.cs -test: mocha -``` From 4c743fcde0c1a18d539420ab568ae73c97ba80b3 Mon Sep 17 00:00:00 2001 From: Takayuki Oda Date: Wed, 1 Feb 2017 16:19:24 +0900 Subject: [PATCH 12/15] Update README_ja.md --- README_ja.md | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/README_ja.md b/README_ja.md index 6a415db..87ea584 100644 --- a/README_ja.md +++ b/README_ja.md @@ -22,27 +22,3 @@ public class MainApp ```cs Console.WriteLine("hoge") ``` - -## GitHub を用いたローカル受験の場合 -codecheck コマンドでテストを行う場合、次のように [codecheck.yml](codecheck.yml) を修正する必要があります。 -(提出時にはもとに戻すことを忘れないでください!) - -```yaml -# Before -build: - - mcs src/*.cs -out:TheApp.exe -env: - APP_COMMAND: mono TheApp.exe -main: src/MainApp.cs -test: mocha -``` - -```yaml -# After -build: - - mcs "src/*.cs" -out:TheApp.exe -env: - APP_COMMAND: mono TheApp.exe -main: src/MainApp.cs -test: mocha -``` From d34458e3718235732b335fae9ad2dcc54445eb3d Mon Sep 17 00:00:00 2001 From: TsubasaK111 Date: Tue, 30 May 2017 14:05:06 +0900 Subject: [PATCH 13/15] refactor: modify update format --- src/MainApp.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MainApp.cs b/src/MainApp.cs index 1a5fbb2..18de900 100644 --- a/src/MainApp.cs +++ b/src/MainApp.cs @@ -1,11 +1,13 @@ using System; - + public class MainApp { static public void Main (string[] args) { - foreach (string arg in args) { - Console.WriteLine(arg); + for (int i = 0; i < args.Length; i++) + { + string output = String.Format("argv[{0}]: {0}", i, args[i]); + Console.WriteLine(output); } } } From c6b55cfd5b2292f3fb1974a171cd971c3529c62c Mon Sep 17 00:00:00 2001 From: Shunji Konishi Date: Thu, 15 Feb 2018 20:33:22 +0900 Subject: [PATCH 14/15] args value are not printed as default Default output is like this. ``` > mono TheApp.exe hoge fuga argv[0]: 0 argv[1]: 1 ``` --- src/MainApp.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MainApp.cs b/src/MainApp.cs index 18de900..05e3f51 100644 --- a/src/MainApp.cs +++ b/src/MainApp.cs @@ -6,7 +6,7 @@ static public void Main (string[] args) { for (int i = 0; i < args.Length; i++) { - string output = String.Format("argv[{0}]: {0}", i, args[i]); + string output = String.Format("argv[{0}]: {1}", i, args[i]); Console.WriteLine(output); } } From 076deff2a506e9f491c80ddb3e5f03a675687d4c Mon Sep 17 00:00:00 2001 From: TsubasaK111 Date: Mon, 19 Feb 2018 16:44:17 +0900 Subject: [PATCH 15/15] fix: add main --- cli-template.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/cli-template.yml b/cli-template.yml index 5936219..7dbc6bc 100644 --- a/cli-template.yml +++ b/cli-template.yml @@ -3,4 +3,5 @@ build: files: - .gitignore - src/MainApp.cs +main: src/MainApp.cs command: mono TheApp.exe