summaryrefslogtreecommitdiff
path: root/src/biruda.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-12-04 09:47:09 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2014-12-04 09:47:09 +0100
commitd5d78969be2903d30b948ba14353e6d476eb32a8 (patch)
treeea076c969484635f3a4d53fc7b700decdbadef9e /src/biruda.c
parentf30a66ffe8752d370ad211f9e331ed25538a263e (diff)
downloadbiruda-d5d78969be2903d30b948ba14353e6d476eb32a8.tar.gz
biruda-d5d78969be2903d30b948ba14353e6d476eb32a8.tar.bz2
added a -F <commandfile> option for easier batch execution
Diffstat (limited to 'src/biruda.c')
-rw-r--r--src/biruda.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/biruda.c b/src/biruda.c
index b900fcc..8e2d9ce 100644
--- a/src/biruda.c
+++ b/src/biruda.c
@@ -300,18 +300,33 @@ int main( int argc, char *argv[] )
return( ( test_config( &args_info ) == 0 ) ? EXIT_SUCCESS : EXIT_FAILURE );
}
- if( args_info.cli_given ) {
+ if( args_info.cli_given || args_info.filename_given ) {
+ FILE *in = stdin;
+ if( args_info.filename_given ) {
+ in = fopen( args_info.filename_arg, "r" );
+ if( in == NULL ) {
+ fprintf( stderr, "ERROR: Unable to open command file '%s'\n", args_info.filename_arg );
+ cfg_free( cfg );
+ cmdline_parser_free( &args_info );
+ exit( EXIT_FAILURE );
+ }
+ }
+ int ret;
#ifndef _WIN32
- int ret = start_interactive( !args_info.no_colors_given );
+ ret = start_interactive( ( in == stdin ) ? !args_info.no_colors_given : false, in );
#else
- fprintf( stderr, "FATAL: No CLI mode implemented for Windows currently!\n" );
- int ret = -1;
+ if( args_info.filename_given ) {
+ ret = start_interactive( false, in );
+ } else {
+ fprintf( stderr, "FATAL: No CLI mode implemented for Windows currently!\n" );
+ ret = -1;
+ }
#endif
cfg_free( cfg );
cmdline_parser_free( &args_info );
- return( ( ret == 0 ) ? EXIT_SUCCESS : EXIT_FAILURE );
+ exit( ( ret == 0 ) ? EXIT_SUCCESS : EXIT_FAILURE );
}
-
+
unsigned int has_master = cfg_size( cfg, "master" );
if( has_master ) {
if( create_master( cfg ) != 0 ) {