Changeset 4712
- Timestamp:
- Aug 4, 2005, 7:17:50 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r4711 r4712 1 %%% $Id: psLibSDRS.tex,v 1.32 2 2005-08-05 03:51:16price Exp $1 %%% $Id: psLibSDRS.tex,v 1.323 2005-08-05 05:17:50 price Exp $ 2 2 \documentclass[panstarrs,spec]{panstarrs} 3 3 … … 1659 1659 are processed. The function shall return the resultant logging level. 1660 1660 1661 \begin{prototype} 1662 bool psArgumentParse(psMetadata *arguments, int *argc, char **argv); 1663 \end{prototype} 1664 1665 \code{psArgumentParse} shall parse the command line arguments 1666 (supplied via \code{argc, argv}) into a metadata container of 1667 \code{arguments}. The input \code{arguments} shall contain the list 1668 of possible arguments (lacking a leading dash) as the keywords 1669 providing the default values (of the appropriate type). As matching 1670 arguments are found on the command line, the values shall be read into 1671 the \code{arguments} metadata, with the appropriate type. Multiple 1672 values (i.e., when an argument takes two or more values) are specified 1673 using a \code{PS_DATA_METADATA_MULTI} list (i.e., by specifying a type 1674 with the \code{PS_META_DUPLICATE_OK} flag). A boolean argument shall 1675 be set to \code{true} by the presence of the argument itself (no value 1676 is specified). The arguments and their values shall be removed from 1677 the list of command line arguments as they are processed. The 1678 function shall return \code{false} without modifying the 1679 \code{arguments} if any argument (i.e., a string beginning with a 1680 dash; but not a string that does not start with a dash, which is 1681 likely a mandatory argument for the program) was encountered that is 1682 not present in the \code{arguments}. 1683 1684 \begin{prototype} 1685 void psArgumentHelp(psMetadata *arguments); 1686 \end{prototype} 1687 1688 \code{psArgumentHelp} shall print to \code{stdout} a guide to the 1689 command-line \code{arguments} (containing the same information as for 1690 \code{psArgumentParse}) of the form: 1691 \begin{verbatim} 1692 Optional arguments: 1693 -names FRED This is the comment from the first value 1694 JIM This is the comment from the second value 1695 BOB This is the comment from the third value 1696 -answer 42 This is a comment 1697 -truth FALSE This is another comment 1698 \end{verbatim} 1699 Here the \code{arguments} contains three keywords, \code{names, magic, 1700 truth}. \code{names} has three values, \code{FRED, JIM, BOB}, stored 1701 as a \code{PS_DATA_METADATA_MULTI}, each with the comment as shown. 1702 1703 It will be the responsibility of the user to supply information for 1704 the mandatory arguments. An example follows: 1705 \begin{verbatim} 1706 void help(psMetadata *arguments, // Command-line arguments 1707 const char *programName // Name of the program = argv[0] 1708 ) 1709 { 1710 printf("Pan-STARRS Phase 2 processing\n\n"); 1711 printf("Usage: %s INPUT.fits OUTPUT.fits\n\n", programName); 1712 psArgumentHelp(arguments); 1713 } 1714 1715 int main(int argc, char *argv[]) 1716 { 1717 // Parse optional command-line arguments 1718 psMetadata *arguments = psMetadataAlloc(); // The arguments, with default values 1719 psMetadataAddStr(arguments, PS_LIST_TAIL, "bias", "Name of the bias image", NULL); 1720 psMetadataAddStr(arguments, PS_LIST_TAIL, "dark", "Name of the dark image", NULL); 1721 psMetadataAddStr(arguments, PS_LIST_TAIL, "flat", "Name of the flat-field image", NULL); 1722 psMetadataAddS32(arguments, PS_LIST_TAIL, "chip", "Chip number to process (if positive)", -1); 1723 psMetadataAddS32(arguments, PS_LIST_TAIL | PS_META_DUPLICATE_OK, "timerange", "The lower time value", 0); 1724 psMetadataAddS32(arguments, PS_LIST_TAIL, "timerange", "The upper time value", 10); 1725 psMetadataAddBool(arguments, PS_LIST_TAIL, "ok", "Is this OK?", FALSE); 1726 if (! psArgumentParse(arguments, &argc, argv) || argc != 2) { 1727 help(arguments, argv[0]); 1728 exit(EXIT_FAILURE); 1729 } 1730 \end{verbatim} 1731 1732 1661 1733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1662 1734
Note:
See TracChangeset
for help on using the changeset viewer.
