authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-20 04:25:42-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-20 04:25:42-04:00
logf248ef5f3f1c78d526e637f4ef08fa40c2ee15c3
tree5b74e8a618a9cb45f866fb778107b8bf51b0835a
parentd9dd50d74c282aefcb89ca922523916b88a6236f

move zen of zig to a sub command


2 files changed, 20 insertions(+), 13 deletions(-)

README.md-13
......@@ -127,16 +127,3 @@ produced .gcov files.
127127 * [zig-mode](https://github.com/AndreaOrru/zig-mode) - Emacs integration
128128 * [zig.vim](https://github.com/zig-lang/zig.vim) - Vim configuration files
129129 * [vscode-zig](https://github.com/zig-lang/vscode-zig) - Visual Studio Code extension
130
131## The Zen of Zig
132
133 * Communicate intent precisely.
134 * Edge cases matter.
135 * Favor reading code over writing code.
136 * Only one obvious way to do things.
137 * Runtime crashes are better than bugs.
138 * Compile errors are better than runtime crashes.
139 * Minimize energy spent on coding style.
140 * Incremental improvements.
141 * Avoid local maximums.
142 * Together we serve the end users.
src/main.cpp+20
......@@ -27,6 +27,7 @@ static int usage(const char *arg0) {
2727 " targets list available compilation targets\n"
2828 " test [source] create and run a test build\n"
2929 " version print version number and exit\n"
30 " zen print zen of zig and exit\n"
3031 "Compile Options:\n"
3132 " --assembly [source] add assembly file to build\n"
3233 " --cache-dir [path] override the cache directory\n"
......@@ -79,6 +80,18 @@ static int usage(const char *arg0) {
7980 return EXIT_FAILURE;
8081}
8182
83static const char *ZIG_ZEN = "\n"
84" * Communicate intent precisely.\n"
85" * Edge cases matter.\n"
86" * Favor reading code over writing code.\n"
87" * Only one obvious way to do things.\n"
88" * Runtime crashes are better than bugs.\n"
89" * Compile errors are better than runtime crashes.\n"
90" * Minimize energy spent on coding style.\n"
91" * Incremental improvements.\n"
92" * Avoid local maximums.\n"
93" * Together we serve the end users.\n";
94
8295static int print_target_list(FILE *f) {
8396 ZigTarget native;
8497 get_native_target(&native);
......@@ -118,6 +131,7 @@ enum Cmd {
118131 CmdBuild,
119132 CmdTest,
120133 CmdVersion,
134 CmdZen,
121135 CmdParseH,
122136 CmdTargets,
123137};
......@@ -457,6 +471,8 @@ int main(int argc, char **argv) {
457471 out_type = OutTypeLib;
458472 } else if (strcmp(arg, "version") == 0) {
459473 cmd = CmdVersion;
474 } else if (strcmp(arg, "zen") == 0) {
475 cmd = CmdZen;
460476 } else if (strcmp(arg, "parseh") == 0) {
461477 cmd = CmdParseH;
462478 } else if (strcmp(arg, "test") == 0) {
......@@ -481,6 +497,7 @@ int main(int argc, char **argv) {
481497 }
482498 break;
483499 case CmdVersion:
500 case CmdZen:
484501 case CmdTargets:
485502 fprintf(stderr, "Unexpected extra parameter: %s\n", arg);
486503 return usage(arg0);
......@@ -682,6 +699,9 @@ int main(int argc, char **argv) {
682699 case CmdVersion:
683700 printf("%s\n", ZIG_VERSION_STRING);
684701 return EXIT_SUCCESS;
702 case CmdZen:
703 printf("%s\n", ZIG_ZEN);
704 return EXIT_SUCCESS;
685705 case CmdTargets:
686706 return print_target_list(stdout);
687707 case CmdInvalid: