mirror of
				https://github.com/onyx-and-iris/vmrcli.git
				synced 2025-10-26 10:51:54 +00:00 
			
		
		
		
	add -I flag for disabling >> on the interactive prompt
				
					
				
			return early from parse_input() if input is a comment add comments to example_commands.txt upd README. minor ver bump
This commit is contained in:
		
							parent
							
								
									39540e9c3e
								
							
						
					
					
						commit
						b35a29396b
					
				| @ -13,13 +13,14 @@ | ||||
| ## `Use` | ||||
| 
 | ||||
| ```powershell | ||||
| .\vmrcli.exe [-h] [-i] [-k] [-D] [-v] [-c] [-m] [-s] <api commands> | ||||
| .\vmrcli.exe [-h] [-i|-I] [-k] [-D] [-v] [-c] [-m] [-s] <api commands> | ||||
| ``` | ||||
| 
 | ||||
| Where: | ||||
| 
 | ||||
| - `h`: Prints the help message. | ||||
| - `i`: Enable interactive mode. If set, any api commands passed on the command line will be ignored. | ||||
| - `i`: Enable interactive mode, use (-I) to disable the '>>' prompt. | ||||
|   - If set, any api commands passed on the command line will be ignored. | ||||
| - `k`: The kind of Voicemeeter (basic, banana or potato). Use this to launch the GUI. | ||||
| - `D`: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL | ||||
| - `v`: Enable extra console output (toggle, set messages) | ||||
| @ -75,11 +76,13 @@ Scripts can be loaded from text files, for example in Powershell: | ||||
| You may also pipe a scripts contents to the CLI: | ||||
| 
 | ||||
| ```powershell | ||||
| $(Get-Content .\example_commands.txt) | .\vmrcli.exe -D1 -i | ||||
| $(Get-Content .\example_commands.txt) | .\vmrcli.exe -D1 -I | ||||
| ``` | ||||
| 
 | ||||
| Multiple API commands can be in a single line, they may be separated by space, `;` or `,`. | ||||
| 
 | ||||
| Lines starting with `#` will be interpreted as comments. | ||||
| 
 | ||||
| ## `Build` | ||||
| 
 | ||||
| Run the included `makefile` with [GNU Make](https://www.gnu.org/software/make/). | ||||
|  | ||||
| @ -1,5 +1,14 @@ | ||||
| # Strip 0 | ||||
| strip[0].mute !strip[0].mute strip[0].mute strip[0].gain strip[0].label=podmic strip[0].label | ||||
| 
 | ||||
| # Strip 1 | ||||
| strip[1].mute=1 strip[1].mute strip[1].limit-=8 | ||||
| 
 | ||||
| # Strip 2 | ||||
| strip[2].gain-=5 strip[2].comp+=4.8 | ||||
| 
 | ||||
| # Bus 0 | ||||
| bus[0].label | ||||
| 
 | ||||
| # Bus 1 | ||||
| bus[1].gain-=5.8 | ||||
| @ -11,5 +11,6 @@ | ||||
| void remove_last_part_of_path(char *fullpath); | ||||
| char *kind_as_string(char *s, int kind, int n); | ||||
| char *version_as_string(char *s, long v, int n); | ||||
| bool is_comment(char *s); | ||||
| 
 | ||||
| #endif /* __UTIL_H__ */ | ||||
| @ -3,7 +3,7 @@ | ||||
|  * @author Vincent Burel, Onyx and Iris (code@onyxandiris.online) | ||||
|  * @brief Functions for initializing the iVMR interface. | ||||
|  * Defines a single public function that returns a pointer to the interface. | ||||
|  * @version 0.7.0 | ||||
|  * @version 0.8.0 | ||||
|  * @date 2024-07-06 | ||||
|  * | ||||
|  * @copyright Vincent Burel(c)2015-2021 All Rights Reserved | ||||
|  | ||||
							
								
								
									
										14
									
								
								src/util.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/util.c
									
									
									
									
									
								
							| @ -2,7 +2,7 @@ | ||||
|  * @file util.c | ||||
|  * @author Onyx and Iris (code@onyxandiris.online) | ||||
|  * @brief Utility functions. | ||||
|  * @version 0.7.0 | ||||
|  * @version 0.8.0 | ||||
|  * @date 2024-07-06 | ||||
|  * | ||||
|  * @copyright Copyright (c) 2024 | ||||
| @ -69,4 +69,16 @@ char *version_as_string(char *s, long v, int n) | ||||
|          v4 = (v & 0x000000FF); | ||||
|     snprintf(s, n, "%i.%i.%i.%i", (int)v1, (int)v2, (int)v3, (int)v4); | ||||
|     return s; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * @brief Is the current input a comment | ||||
|  * | ||||
|  * @param s Pointer to the current input | ||||
|  * @return true | ||||
|  * @return false | ||||
|  */ | ||||
| bool is_comment(char *s) | ||||
| { | ||||
|     return s[0] == '#'; | ||||
| } | ||||
							
								
								
									
										46
									
								
								src/vmrcli.c
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								src/vmrcli.c
									
									
									
									
									
								
							| @ -2,7 +2,7 @@ | ||||
|  * @file vmrcli.c | ||||
|  * @author Onyx and Iris (code@onyxandiris.online) | ||||
|  * @brief A Voicemeeter Remote Command Line Interface | ||||
|  * @version 0.7.0 | ||||
|  * @version 0.8.0 | ||||
|  * @date 2024-07-06 | ||||
|  * | ||||
|  * @copyright Copyright (c) 2024 | ||||
| @ -21,17 +21,17 @@ | ||||
| #include "log.h" | ||||
| #include "util.h" | ||||
| 
 | ||||
| #define USAGE "Usage: .\\vmrcli.exe [-h] [-i] [-k] [-D] [-v] [-c] [-m] [-s] <api commands>\n" \ | ||||
|               "Where: \n"                                                                     \ | ||||
|               "\th: Prints the help message\n"                                                \ | ||||
|               "\ti: Enable interactive mode\n"                                                \ | ||||
|               "\tk: The kind of Voicemeeter (basic, banana, potato)\n"                        \ | ||||
|               "\tD: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL\n"       \ | ||||
|               "\tv: Enable extra console output (toggle, set messages)\n"                     \ | ||||
|               "\tc: Load a user configuration (give the full file path)\n"                    \ | ||||
|               "\tm: Launch the MacroButtons application\n"                                    \ | ||||
| #define USAGE "Usage: .\\vmrcli.exe [-h] [-i|-I] [-k] [-D] [-v] [-c] [-m] [-s] <api commands>\n" \ | ||||
|               "Where: \n"                                                                        \ | ||||
|               "\th: Prints the help message\n"                                                   \ | ||||
|               "\ti: Enable interactive mode, use (-I) to disable the '>>' prompt\n"              \ | ||||
|               "\tk: The kind of Voicemeeter (basic, banana, potato)\n"                           \ | ||||
|               "\tD: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL\n"          \ | ||||
|               "\tv: Enable extra console output (toggle, set messages)\n"                        \ | ||||
|               "\tc: Load a user configuration (give the full file path)\n"                       \ | ||||
|               "\tm: Launch the MacroButtons application\n"                                       \ | ||||
|               "\ts: Launch the StreamerView application" | ||||
| #define OPTSTR ":hk:msc:iD:v" | ||||
| #define OPTSTR ":hk:msc:iID:v" | ||||
| #define MAX_LINE 512 | ||||
| 
 | ||||
| /**
 | ||||
| @ -60,7 +60,7 @@ static bool vflag = false; | ||||
| 
 | ||||
| static void usage(void); | ||||
| enum kind set_kind(char *kval); | ||||
| void interactive(PT_VMR vmr); | ||||
| void interactive(PT_VMR vmr, bool with_prompt); | ||||
| void parse_input(PT_VMR vmr, char *input); | ||||
| void parse_command(PT_VMR vmr, char *command); | ||||
| void get(PT_VMR vmr, char *command, struct result *res); | ||||
| @ -70,7 +70,8 @@ int main(int argc, char *argv[]) | ||||
|     bool iflag = false, | ||||
|          mflag = false, | ||||
|          sflag = false, | ||||
|          cflag = false; | ||||
|          cflag = false, | ||||
|          with_prompt = true; | ||||
|     int opt; | ||||
|     int dvalue; | ||||
|     char *cvalue; | ||||
| @ -106,6 +107,9 @@ int main(int argc, char *argv[]) | ||||
|             cflag = true; | ||||
|             cvalue = optarg; | ||||
|             break; | ||||
|         case 'I': | ||||
|             with_prompt = false; | ||||
|             [[fallthrough]]; | ||||
|         case 'i': | ||||
|             iflag = true; | ||||
|             break; | ||||
| @ -174,7 +178,7 @@ int main(int argc, char *argv[]) | ||||
|     if (iflag) | ||||
|     { | ||||
|         puts("Interactive mode enabled. Enter 'Q' to exit."); | ||||
|         interactive(vmr); | ||||
|         interactive(vmr, with_prompt); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
| @ -231,11 +235,12 @@ enum kind set_kind(char *kval) | ||||
|  * | ||||
|  * @param vmr Pointer to the iVMR interface | ||||
|  */ | ||||
| void interactive(PT_VMR vmr) | ||||
| void interactive(PT_VMR vmr, bool with_prompt) | ||||
| { | ||||
|     char input[MAX_LINE]; | ||||
| 
 | ||||
|     printf(">> "); | ||||
|     if (with_prompt) | ||||
|         printf(">> "); | ||||
|     while (fgets(input, MAX_LINE, stdin) != NULL) | ||||
|     { | ||||
|         input[strcspn(input, "\n")] = 0; | ||||
| @ -245,12 +250,14 @@ void interactive(PT_VMR vmr) | ||||
|         parse_input(vmr, input); | ||||
| 
 | ||||
|         memset(input, 0, MAX_LINE); /* reset input buffer */ | ||||
|         printf(">> "); | ||||
|         if (with_prompt) | ||||
|             printf(">> "); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * @brief Walks through each line split by " \t;," delimiters. | ||||
|  * @brief Returns early if input is a comment | ||||
|  * Walks through each line split by " \t;," delimiters. | ||||
|  * Each token is passed to parse_command() | ||||
|  * | ||||
|  * @param vmr Pointer to the iVMR interface | ||||
| @ -258,6 +265,9 @@ void interactive(PT_VMR vmr) | ||||
|  */ | ||||
| void parse_input(PT_VMR vmr, char *input) | ||||
| { | ||||
|     if (is_comment(input)) | ||||
|         return; | ||||
| 
 | ||||
|     char *token, *p; | ||||
| 
 | ||||
|     token = strtok_r(input, " \t;,", &p); | ||||
|  | ||||
| @ -2,7 +2,7 @@ | ||||
|  * @file wrapper.c | ||||
|  * @author Onyx and Iris (code@onyxandiris.online) | ||||
|  * @brief Provides public functions that wrap the iVMR calls | ||||
|  * @version 0.7.0 | ||||
|  * @version 0.8.0 | ||||
|  * @date 2024-07-06 | ||||
|  * | ||||
|  * @copyright Copyright (c) 2024 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user