1
0

template.c: port all CLI arguments into the script

src/template.c:
1. Port all command line arguments into script `bytebeat_generator.py`
2. Remove the submodule lib/c-argh
This commit is contained in:
Intel A80486DX2-66 2023-11-25 20:34:11 +03:00
parent 64cfda4a33
commit 3acc0be646
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B
4 changed files with 8 additions and 19 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "lib/c-argh"]
path = lib/c-argh
url = git@git.disroot.org:80486DX2-66/c-argh.git

View File

@ -78,6 +78,8 @@ if __name__ == "__main__":
help="length (seconds)") help="length (seconds)")
parser.add_argument("-a", "--no-return", default=False, action="store_true", parser.add_argument("-a", "--no-return", default=False, action="store_true",
help="do not insert return statement before the code") help="do not insert return statement before the code")
parser.add_argument("-q", "--silent", default=False, action="store_true",
help="do not output anything during generation")
args = parser.parse_args() args = parser.parse_args()
bytebeat_contents = read_from_file_or_stdin(args.file).strip() bytebeat_contents = read_from_file_or_stdin(args.file).strip()
@ -113,6 +115,8 @@ if __name__ == "__main__":
args.channels, substitute) args.channels, substitute)
substitute = substitute_var("seconds", substitute = substitute_var("seconds",
args.seconds, substitute) args.seconds, substitute)
substitute = substitute_var("silent_mode",
"true" if args.silent else "false", substitute)
rewrite_file(PATHS["substitute"], substitute) rewrite_file(PATHS["substitute"], substitute)
# Compile by invoking the shell script # Compile by invoking the shell script

@ -1 +0,0 @@
Subproject commit 540d94bd1d41fb19c82c50904c2322c93e6718b3

View File

@ -7,9 +7,6 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
// libraries
#include "../lib/c-argh/argh.h"
// constants // constants
#if defined(_WIN32) #if defined(_WIN32)
# define __ANSI_CLEAR_STRING "\r" # define __ANSI_CLEAR_STRING "\r"
@ -52,7 +49,7 @@ const char* dbgpnt_labels[3] = { "memory allocation",
(unsigned int)(sizeof(dbgpnt_labels) / sizeof(dbgpnt_labels[0])) (unsigned int)(sizeof(dbgpnt_labels) / sizeof(dbgpnt_labels[0]))
// global variables // global variables
bool silent_mode = false; #define SILENT_MODE `silent_mode`
// function prototypes // function prototypes
SAMPLE_TYPE SAMPLE_TYPE
@ -67,22 +64,14 @@ bytebeat(long double w)
`bytebeat_contents`; `bytebeat_contents`;
} }
#define USAGE "render_bytebeat [-s | --silent]"
int int
main(int argc, char** argv) main(void)
{ {
// * parse CLI arguments
ARGH_PARSE {
ARGH_NEXT();
if ARGH_BOOL("-s", "--silent") { silent_mode = true; }
}
// * log -> welcome // * log -> welcome
printf(":: C bytebeat generator runtime unit\n"); printf(":: C bytebeat generator runtime unit\n");
fflush(stdout); fflush(stdout);
if (!silent_mode) { if (!SILENT_MODE) {
printf( printf(
"\n" "\n"
"Sample rate: %d Hz\n" "Sample rate: %d Hz\n"
@ -142,7 +131,7 @@ main(int argc, char** argv)
// 6. log // 6. log
if ( if (
!silent_mode && !SILENT_MODE &&
(w % FREQUENCY_OF_STATUS_REPORTING == 0 || (w % FREQUENCY_OF_STATUS_REPORTING == 0 ||
w >= PRODUCT - 1 /* writing last sample */)) { w >= PRODUCT - 1 /* writing last sample */)) {
printf( printf(