Example #1
0
/*
Print either main usage/help information, or some more specific
information on particular commands.
 */
int
usage( char *subOpt ) {
    int i;
    if ( *subOpt == '\0' ) {
        usageMain();
    }
    else {
        if ( strcmp( subOpt, "create" ) == 0 ) {
            char *msgs[] = {
                " create read/write Object-Name [string] (create a new ticket)",
                "Create a new ticket for Object-Name, which is either a data-object (file)",
                "or a collection (directory). ",
                "Example: create read myFile",
                "The ticket string, which can be used for access, will be displayed.",
                "If 'string' is provided on the command line, it is the ticket-string to use",
                "as the ticket instead of a randomly generated string of characters.",
                ""
            };
            for ( i = 0;; i++ ) {
                if ( strlen( msgs[i] ) == 0 ) {
                    return 0;
                }
                printf( "%s\n", msgs[i] );
            }
        }
        if ( strcmp( subOpt, "mod" ) == 0 ) {
            char *msgs[] = {
                "   mod Ticket-id uses/expire string-or-none",
                "or mod Ticket-id add/remove host/user/group string (modify restrictions)",
                "Modify a ticket to use one of the specialized options.  By default a",
                "ticket can be used by anyone (and 'anonymous'), from any host, and any",
                "number of times, and for all time (until deleted).  You can modify it to",
                "add (or remove) these types of restrictions.",
                " ",
                " 'mod Ticket-id uses integer-or-0' will make the ticket only valid",
                "the specified number of times.  Use 0 to remove this restriction.",
                " ",
                " 'mod Ticket-id write-file integer-or-0' will make the write-ticket only",
                "valid for writing the specified number of times.  Use 0 to remove this",
                "restriction.",
                " ",
                " 'mod Ticket-id write-byte integer-or-0' will make the write-ticket only",
                "valid for writing the specified number of bytes.  Use 0 to remove this",
                "restriction.",
                " ",
                " 'mod Ticket-id add/remove user Username' will make the ticket only valid",
                "when used by that particular iRODS user.  You can use multiple mod commands",
                "to add more users to the allowed list.",
                " ",
                " 'mod Ticket-id add/remove group Groupname' will make the ticket only valid",
                "when used by iRODS users in that particular iRODS group.  You can use",
                "multiple mod commands to add more groups to the allowed list.",
                " ",
                " 'mod Ticket-id add/remove host Host/IP' will make the ticket only valid",
                "when used from that particular host computer.  Host (full DNS name) will be",
                "converted to the IP address for use in the internal checks or you can enter",
                "the IP address itself.  'iticket ls' will display the IP addresses.",
                "You can use multiple mod commands to add more hosts to the list.",
                " ",
                " 'mod Ticket-id expire date.time-or-0' will make the ticket only valid",
                "before the specified date-time.  You can cancel this expiration by using",
                "'0'.  The time is year-mo-da.hr:min:sec, for example: 2012-05-07.23:00:00",
                " ",
                " The Ticket-id is either the ticket object number or the ticket-string",
                ""
            };
            for ( i = 0;; i++ ) {
                if ( strlen( msgs[i] ) == 0 ) {
                    return 0;
                }
                printf( "%s\n", msgs[i] );
            }
        }
        if ( strcmp( subOpt, "delete" ) == 0 ) {
            char *msgs[] = {
                " delete Ticket-string",
                "Remove a ticket from the system.  Access will no longer be allowed",
                "via the ticket-string.",
                ""
            };
            for ( i = 0;; i++ ) {
                if ( strlen( msgs[i] ) == 0 ) {
                    return 0;
                }
                printf( "%s\n", msgs[i] );
            }
        }

        if ( strcmp( subOpt, "ls" ) == 0 ) {
            char *msgs[] = {
                " ls [Ticket_string-or-id]",
                "List the tickets owned by you or, for admin users, all tickets.",
                "Include a ticket-string or the ticket-id (object number) to list only one",
                "(in this case, a numeric string is assumed to be an id).",
                ""
            };
            for ( i = 0;; i++ ) {
                if ( strlen( msgs[i] ) == 0 ) {
                    return 0;
                }
                printf( "%s\n", msgs[i] );
            }
        }

        if ( strcmp( subOpt, "ls-all" ) == 0 ) {
            char *msgs[] = {
                " ls-all",
                "Similar to 'ls' (with no ticket string-or-id) but will list all of your",
                "tickets even if the target collection or data-object no longer exists.",
                ""
            };
            for ( i = 0;; i++ ) {
                if ( strlen( msgs[i] ) == 0 ) {
                    return 0;
                }
                printf( "%s\n", msgs[i] );
            }
        }
        printf( "Sorry, either %s is an invalid command or the help has not been written yet\n",
                subOpt );
    }
    return 0;
}
Example #2
0
void
usage(char *subOpt)
{
   char *mkuserMsgs[]={
" mkuser Name Group Password (make user by a group-admin)",
"Create a new iRODS user in the ICAT database",
" ",
"Name is the user name to create",
"Group is the group to also add the user to",
"Password is the user's initial password",
" ",
"The user type will be automatically set to 'rodsuser' and the zone local."
""};

   char *lgMsgs[]={
" lg [name] (list group info (user member list))",
"Just 'lg' briefly lists the defined groups.",
"If you include a group name, it will list users who are",
"members of that group.  Users are listed in the user#zone format.",
"In addition to 'rodsadmin', any user can use this sub-command; this is",
"of most value to 'groupadmin' users who can also atg, rfg, and mkuser.",
""};

   char *atgMsgs[]={
" atg groupName userName[#userZone] (add to group - add a user to a group)",
"For remote-zone users, include the userZone.",
"Also see mkgroup, rfg and rmgroup.",
"In addition to the 'rodsadmin', users of type 'groupadmin' can atg and rfg",
"for groups they are members of.  They can see group membership via iuserinfo.",
""};

   char *rfgMsgs[]={
" rfg groupName userName[#userZone] (remove from group - remove a user from a group)",
"For remote-zone users, include the userZone.",
"Also see mkgroup, afg and rmgroup.",
"In addition to the 'rodsadmin', users of type 'groupadmin' can atg and rfg",
"for groups they are members of.  They can see group membership via iuserinfo.",
""};

   char *mkgroupMsgs[]={
" mkgroup groupName[#Zone] (make a new group)",
"Make a new group.  You will need to add yourself to the new group to then",
"be able to add and remove others (when the group is empty groupadmins are",
"allowed to add themselves.)",
""};

   char *helpMsgs[]={
" help (or h) [command] (general help, or more details on a command)",
" If you specify a command, a brief description of that command",
" will be displayed.",
""};

   char *subCmds[]={
                    "lg",
		    "mkuser",
		    "atg",
		    "rfg",
		    "mkgroup",
		    "help", "h",
		    ""};

   char **pMsgs[]={ 
                    lgMsgs,
		    mkuserMsgs,
		    atgMsgs, 
		    rfgMsgs,
		    mkgroupMsgs,
		    helpMsgs, helpMsgs };

   if (*subOpt=='\0') {
      usageMain();
   }
   else {
      int i;
      for (i=0;;i++) {
	 if (strlen(subCmds[i])==0) break;
	 if (strcmp(subOpt,subCmds[i])==0) {
	    printMsgs(pMsgs[i]);
	 }
      }
   }
}
Example #3
0
File: imeta.c Project: UPPMAX/irods
/*
Print either main usage/help information, or some more specific
information on particular commands.
 */
int
usage(char *subOpt)
{
   int i;
   if (*subOpt=='\0') {
      usageMain();
   }
   else {
      if (strcmp(subOpt,"add")==0) {
	 char *msgs[]={
" add -d|C|R|G|u Name AttName AttValue [AttUnits]  (Add new AVU triplet)", 
"Add an AVU to a dataobj (-d), collection(-C), resource(-R), ",
"resource group(-G) or user(-u)",
"Example: add -d file1 distance 12 miles",
" ",
"Admins can also use the command 'adda' (add as admin) to add metadata",
"to any collection or dataobj; syntax is the same as 'add'.  Admins are",
"also allowed to add user and resource metadata.",
""};
	 for (i=0;;i++) {
	    if (strlen(msgs[i])==0) return(0);
	    printf("%s\n",msgs[i]);
	 }
      }
      if (strcmp(subOpt,"addw")==0) {
	 char *msgs[]={
" addw -d Name AttName AttValue [AttUnits]  (Add new AVU triplet)", 
"Add an AVU to a set of data-objects using wildcards to match",
"the data-object names.",
" ",
"The character _ matches any single character and % matches any",
"number of any characters.",
" ",
"Example: addw -d file% distance 12 miles",
"would add the AVU to dataobjects in the current directory with names",
"that start with 'file'.",
" ",
"Example2: addw -d /tempZone/home/rods/test/%/% distance 12 miles",
"would add the AVU to all dataobjects in the 'test' collection or any",
"subcollections under 'test'.",
""};
	 for (i=0;;i++) {
	    if (strlen(msgs[i])==0) return(0);
	    printf("%s\n",msgs[i]);
	 }
      }
      if (strcmp(subOpt,"rm")==0) {
	 char *msgs[]={
" rm  -d|C|R|G|u Name AttName AttValue [AttUnits] (Remove AVU)", 
"Remove an AVU from a dataobj (-d), collection(-C), resource(-R),",
"resource group(-G) or user(-u)",
"Example: rm -d file1 distance 12 miles",
"An AttUnits value must be included if it was when the AVU was added.",
"Also see rmw for use of wildcard characters.",
""};
	 for (i=0;;i++) {
	    if (strlen(msgs[i])==0) return(0);
	    printf("%s\n",msgs[i]);
	 }
      }
      if (strcmp(subOpt,"rmw")==0) {
	 char *msgs[]={
" rmw  -d|C|R|G|u Name AttName AttValue [AttUnits] (Remove AVU, use Wildcard)", 
"Remove an AVU from a dataobj (-d), collection(-C), resource(-R), ",
"resource group(-G) or user(-u)",
"An AttUnits value must be included if it was when the AVU was added.",
"rmw is very similar to rm but using SQL wildcard characters, _ and %.",
"The _ matches any single character and % matches any number of any",
"characters.  Examples:",
"  rmw -d file1 distance % %",
" or ",
"  rmw -d file1 distance % m% ",
" ",
"Note that if the attributes contain the characters '%' or '_', ",
"the rmw command still do matching using them as wildcards, so you may",
"need to use rm instead.",
"Also see lsw.",
""};
	 for (i=0;;i++) {
	    if (strlen(msgs[i])==0) return(0);
	    printf("%s\n",msgs[i]);
	 }
      }
      if (strcmp(subOpt,"mod")==0) {
	 char *msgs[]={
" mod -d|C|R|G|u Name AttName AttValue [AttUnits] [n:Name] [v:Value] [u:Units]", 
"      (modify AVU; new name (n:), value(v:), and/or units(u:)",
"Modify a defined AVU for the specified item (object)",
"Example: mod -d file1 distance 14 miles v:27",
" ",
"Only the AVU associated with this object is modified.  Internally, the system",
"removes the old AVU from the object and creates a new one (ensuring",
"consistency), and performs a single 'commit' if all is valid.",
""};
	 for (i=0;;i++) {
	    if (strlen(msgs[i])==0) return(0);
	    printf("%s\n",msgs[i]);
	 }
      }
      if (strcmp(subOpt,"ls")==0) {
	 char *msgs[]={
" ls -d|C|R|G|u Name [AttName] (List existing AVUs for item Name)", 
" ls -ld Name [AttName]        (List in long format)", 
"List defined AVUs for the specified item",
"Example: ls -d file1",
"If the optional AttName is included, it is the attribute name",
"you wish to list and only those will be listed.",
"If the optional -l is used on dataObjects (-ld), the long format will",
"be displayed which includes the time the AVU was set.",
"Also see lsw.",
""};
	 for (i=0;;i++) {
	    if (strlen(msgs[i])==0) return(0);
	    printf("%s\n",msgs[i]);
	 }
      }

      if (strcmp(subOpt,"lsw")==0) {
	 char *msgs[]={
" lsw -d|C|R|G|u Name [AttName] (List existing AVUs, use Wildcards)", 
"List defined AVUs for the specified item",
"Example: lsw -d file1",
"If the optional AttName is included, it is the attribute name",
"you wish to list, doing so using wildcard matching.",
"For example: ls -d file1 attr%",
"If the optional -l is used on dataObjects (-ld), the long format will",
"be displayed which includes the time the AVU was set.",
"Also see rmw and ls.",
""};
	 for (i=0;;i++) {
	    if (strlen(msgs[i])==0) return(0);
	    printf("%s\n",msgs[i]);
	 }
      }

      if (strcmp(subOpt,"set")==0) {
	char *msgs[]={
" set -d|C|R|G|u Name AttName newValue [newUnits]  (assign a single value)", 
"Set the newValue (and newUnit) of an AVU of a dataobj (-d), collection(-C),",
"     resource(-R), resource group(-G) or user(-u).",
" ",
"'set' modifies an AVU if it exists, or creates one if it does not.",
"If the AttName does not exist, or is used by multiple objects, the AVU for",
"this object is added.",
"If the AttName is used only by this one object, the AVU (row) is modified",
"with the new values, reducing the database overhead (unused rows).",
"Example: set -d file1 distance 12",
""};
	 for (i=0;;i++) {
	   if (strlen(msgs[i])==0) return(0);
 	    printf("%s\n",msgs[i]);
 	 }
      }

      if (strcmp(subOpt,"qu")==0) {
	 char *msgs[]={
" qu -d|C|R|G|u AttName Op AttVal [...] (Query objects with matching AVUs)", 
"Query across AVUs for the specified type of item",
"Example: qu -d distance '<=' 12",
" ",
"When querying dataObjects (-d) or collections (-C) additional conditions",
"(AttName Op AttVal) may be given separated by 'and', for example:",
" qu -d a = b and c '<' 10",
"Or a single 'or' can be given for the same AttName, for example",
" qu -d r '<' 5 or '>' 7",
" ",
"You can also query in numeric mode (instead of as strings) by adding 'n'",
"in front of the test condition, for example:",
" qu -d r 'n<' 123",
"which causes it to cast the AVU column to numeric (decimal) in the SQL.",
"In numeric mode, if any of the named AVU values are non-numeric, a SQL",
"error will occur but this avoids problems when comparing numeric strings",
"of different lengths.",
" ",
"Other examples:",
" qu -d a like b%",
"returns data-objects with attribute 'a' with a value that starts with 'b'.",
" qu -d a like %",
"returns data-objects with attribute 'a' defined (with any value).",
""};
	 for (i=0;;i++) {
	    if (strlen(msgs[i])==0) return(0);
	    printf("%s\n",msgs[i]);
	 }
      }
      if (strcmp(subOpt,"cp")==0) {
	 char *msgs[]={
" cp -d|C|R|G|u -d|C|R|G|u Name1 Name2 (Copy AVUs from item Name1 to Name2)", 
"Example: cp -d -C file1 dir1",
""};
	 for (i=0;;i++) {
	    if (strlen(msgs[i])==0) return(0);
	    printf("%s\n",msgs[i]);
	 }
      }
      printf("Sorry, either %s is an invalid command or the help has not been written yet\n",
	     subOpt);
   }
   return(0);
}