Changeset - feebc1df83c1
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 15 years ago 2010-07-25 17:36:54
ohnobinki@ohnopublishing.net
Exit if -h is passed.
1 file changed with 1 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/client/distren.c
Show inline comments
 
@@ -42,100 +42,97 @@
 
int main_opt_set(const char *name, char **dst, const char *src);
 

	
 
int main(int argc, char *argv[])
 
{
 
  short dologin;
 
  short printinfo;
 
  short lazy;
 

	
 
  char *input;
 
  char *output;
 
  char *joburi;
 

	
 
  char *username;
 
  char *password;
 

	
 
  char curopt;
 

	
 
  distren_t distren;
 
  distren_job_t distren_job;
 

	
 
  dologin = 0;
 
  printinfo = 0;
 
  lazy = 1;
 

	
 
  input = NULL;
 
  output = NULL;
 
  joburi = NULL;
 

	
 
  while(-1 != (curopt = getopt(argc, argv, "di:j:o:u:p:h")))
 
    {
 
      switch(curopt)
 
	{
 
	case ':':
 
	  fprintf(stderr, "-%c: is missing an argument\n", optopt);
 
	  return 1;
 

	
 
	case '?':
 
	  fprintf(stderr, "-%c: invalid option specified\n", optopt);
 
	  return 1;
 

	
 
	case 'h':
 
	  fprintf(stderr, "Usage: %s [-u <username>] [-p <password>] ...\n", argv[0]);
 
	  fprintf(stderr, "\t-i\tSpecifies an input file to submit to the server.\n\
 
\t-o\tSpecifies the name that should be given to a job retrieved from the server.\n\
 
\t-j\tSpecifies the job handle of a job to view information about or retrieve.\n\
 
\t-d\tDisplays information about the job specified with -j or uploaded by -i.\n\
 
\t-h\tShows this help message.\n");
 
	  
 
	  /*
 
	   * don't return here because options_init will have an
 
	   * overall options help page
 
	   */
 
	  return 0;
 
	  break;
 

	
 
	case 'u':
 
	  main_opt_set("-u", &username, optarg);
 
	  dologin = 1;
 
	  break;
 

	
 
	case 'p':
 
	  main_opt_set("-p", &password, optarg);
 
	  dologin = 1;
 
	  break;
 

	
 
	case 'i':
 
	  if(joburi)
 
	    {
 
	      fprintf(stderr, "You may not specify both -i and -j; -j must refer to an existing job URL and -i will create a new job and thus retrieve its URL.\n");
 
	      return 1;
 
	    }
 
	  main_opt_set("-i", &input, optarg);
 
	  break;
 

	
 
	case 'o':
 
	  main_opt_set("-o", &output, optarg);
 
	  break;
 

	
 
	case 'j':
 
	  if(input)
 
	    {
 
	      fprintf(stderr, "You may not specify both -j and -i; -i is submitting a new jobs whose URL cannot be known before it is submitted\n");
 
	      return 1;
 
	    }
 
	  main_opt_set("-j", &joburi, optarg);
 
	  break;
 

	
 
	case 'd':
 
	  printinfo = 1;
 
	  break;
 
	}
 
    }
 

	
 
  
 
     // give this error after the general arguments parsing so that
 
     // the general help from options_init can have effect
 
  if(!username || !password)
 
    {
 
      fprintf(stderr, "Username and password must be specified:\n");
 
      if(!username)
 
	fprintf(stderr, "\tyou did not specify a username\n");
0 comments (0 inline, 0 general)