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....@@ -127,16 +127,3 @@ produced .gcov files.
127 * [zig-mode](https://github.com/AndreaOrru/zig-mode) - Emacs integration127 * [zig-mode](https://github.com/AndreaOrru/zig-mode) - Emacs integration
128 * [zig.vim](https://github.com/zig-lang/zig.vim) - Vim configuration files128 * [zig.vim](https://github.com/zig-lang/zig.vim) - Vim configuration files
129 * [vscode-zig](https://github.com/zig-lang/vscode-zig) - Visual Studio Code extension129 * [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) {...@@ -27,6 +27,7 @@ static int usage(const char *arg0) {
27 " targets list available compilation targets\n"27 " targets list available compilation targets\n"
28 " test [source] create and run a test build\n"28 " test [source] create and run a test build\n"
29 " version print version number and exit\n"29 " version print version number and exit\n"
30 " zen print zen of zig and exit\n"
30 "Compile Options:\n"31 "Compile Options:\n"
31 " --assembly [source] add assembly file to build\n"32 " --assembly [source] add assembly file to build\n"
32 " --cache-dir [path] override the cache directory\n"33 " --cache-dir [path] override the cache directory\n"
...@@ -79,6 +80,18 @@ static int usage(const char *arg0) {...@@ -79,6 +80,18 @@ static int usage(const char *arg0) {
79 return EXIT_FAILURE;80 return EXIT_FAILURE;
80}81}
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
82static int print_target_list(FILE *f) {95static int print_target_list(FILE *f) {
83 ZigTarget native;96 ZigTarget native;
84 get_native_target(&native);97 get_native_target(&native);
...@@ -118,6 +131,7 @@ enum Cmd {...@@ -118,6 +131,7 @@ enum Cmd {
118 CmdBuild,131 CmdBuild,
119 CmdTest,132 CmdTest,
120 CmdVersion,133 CmdVersion,
134 CmdZen,
121 CmdParseH,135 CmdParseH,
122 CmdTargets,136 CmdTargets,
123};137};
...@@ -457,6 +471,8 @@ int main(int argc, char **argv) {...@@ -457,6 +471,8 @@ int main(int argc, char **argv) {
457 out_type = OutTypeLib;471 out_type = OutTypeLib;
458 } else if (strcmp(arg, "version") == 0) {472 } else if (strcmp(arg, "version") == 0) {
459 cmd = CmdVersion;473 cmd = CmdVersion;
474 } else if (strcmp(arg, "zen") == 0) {
475 cmd = CmdZen;
460 } else if (strcmp(arg, "parseh") == 0) {476 } else if (strcmp(arg, "parseh") == 0) {
461 cmd = CmdParseH;477 cmd = CmdParseH;
462 } else if (strcmp(arg, "test") == 0) {478 } else if (strcmp(arg, "test") == 0) {
...@@ -481,6 +497,7 @@ int main(int argc, char **argv) {...@@ -481,6 +497,7 @@ int main(int argc, char **argv) {
481 }497 }
482 break;498 break;
483 case CmdVersion:499 case CmdVersion:
500 case CmdZen:
484 case CmdTargets:501 case CmdTargets:
485 fprintf(stderr, "Unexpected extra parameter: %s\n", arg);502 fprintf(stderr, "Unexpected extra parameter: %s\n", arg);
486 return usage(arg0);503 return usage(arg0);
...@@ -682,6 +699,9 @@ int main(int argc, char **argv) {...@@ -682,6 +699,9 @@ int main(int argc, char **argv) {
682 case CmdVersion:699 case CmdVersion:
683 printf("%s\n", ZIG_VERSION_STRING);700 printf("%s\n", ZIG_VERSION_STRING);
684 return EXIT_SUCCESS;701 return EXIT_SUCCESS;
702 case CmdZen:
703 printf("%s\n", ZIG_ZEN);
704 return EXIT_SUCCESS;
685 case CmdTargets:705 case CmdTargets:
686 return print_target_list(stdout);706 return print_target_list(stdout);
687 case CmdInvalid:707 case CmdInvalid: