Browse Source

Implement -x clish utility option to set path to get XMLs from.

git-svn-id: https://klish.googlecode.com/svn/trunk@257 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
2cf9cd656d
3 changed files with 21 additions and 5 deletions
  1. 18 2
      bin/clish.cpp
  2. 1 1
      clish/shell.h
  3. 2 2
      clish/shell/shell_spawn.c

+ 18 - 2
bin/clish.cpp

@@ -47,8 +47,11 @@ int main(int argc, char **argv)
 	const char *socket_path = KONFD_SOCKET_PATH;
 	bool_t lockless = BOOL_FALSE;
 	bool_t stop_on_error = BOOL_FALSE;
+	const char *xml_path = getenv("CLISH_PATH");
+	const char *view = NULL;
+	const char *viewid = NULL;
 
-	static const char *shortopts = "hvs:led";
+	static const char *shortopts = "hvs:ledx:w:i:";
 /*	static const struct option longopts[] = {
 		{"help",	0, NULL, 'h'},
 		{"version",	0, NULL, 'v'},
@@ -56,6 +59,9 @@ int main(int argc, char **argv)
 		{"lockless",	0, NULL, 'l'},
 		{"stop-on-error", 0, NULL, 'e'},
 		{"dry-run",	0, NULL, 'd'},
+		{"xml-path",	1, NULL, 'x'},
+		{"view",	1, NULL, 'w'},
+		{"viewid",	1, NULL, 'i'},
 		{NULL,		0, NULL, 0}
 	};
 */
@@ -80,6 +86,15 @@ int main(int argc, char **argv)
 		case 'd':
 			my_hooks.script_fn = clish_dryrun_callback;
 			break;
+		case 'x':
+			xml_path = optarg;
+			break;
+		case 'w':
+			view = optarg;
+			break;
+		case 'i':
+			viewid = optarg;
+			break;
 		case 'h':
 			help(0, argv[0]);
 			exit(0);
@@ -100,8 +115,9 @@ int main(int argc, char **argv)
 		fprintf(stderr, "Cannot run clish.\n");
 		return -1;
 	}
+
 	/* Load the XML files */
-	clish_shell_load_files(shell);
+	clish_shell_load_scheme(shell, xml_path);
 	/* Set communication to the konfd */
 	clish_shell__set_socket(shell, socket_path);
 	/* Set lockless mode */

+ 1 - 1
clish/shell.h

@@ -367,7 +367,7 @@ int clish_shell_spawn(clish_shell_t * instance,
 int clish_shell_wait(clish_shell_t * instance);
 int clish_shell_spawn_and_wait(clish_shell_t * instance,
 	const pthread_attr_t * attr);
-void clish_shell_load_files(clish_shell_t * instance);
+void clish_shell_load_scheme(clish_shell_t * instance, const char * xml_path);
 bool_t clish_shell_loop(clish_shell_t * instance);
 clish_shell_state_t clish_shell__get_state(const clish_shell_t * instance);
 void clish_shell__set_state(clish_shell_t * instance,

+ 2 - 2
clish/shell/shell_spawn.c

@@ -48,9 +48,9 @@ static char *clish_shell_tilde_expand(const char *path)
 }
 
 /*-------------------------------------------------------- */
-void clish_shell_load_files(clish_shell_t * this)
+void clish_shell_load_scheme(clish_shell_t * this, const char *xml_path)
 {
-	const char *path = getenv("CLISH_PATH");
+	const char *path = xml_path;
 	char *buffer;
 	char *dirname;
 	char *saveptr;