Next: , Previous: Terminology, Up: Top   [Contents][Index]


5 ¥°¥ë¡¼¥×¥ª¥×¥·¥ç¥ó

¥°¥ë¡¼¥×¥ª¥×¥·¥ç¥ó¤â²Äǽ¤Ç¤¹¡¥¥°¥ë¡¼¥×¤Ë½ê°¤¹¤ë¥ª¥×¥·¥ç¥ó¤Ï¡¤ ¤ª¸ß¤¤¤ËÇÓ¾Ū¤Ç¤¢¤ë¤È¹Í褵¤ì¤Þ¤¹¡¥¤³¤Îµ¡Ç½¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¡¤ºÇ ½é¤Ëgroup¤òÄêµÁ¤¹¤ëɬÍפ¬¤¢¤ê¡¤¤½¤Î¸å¤Çgroupoption¤òÄêµÁ ¤¹¤ë¤³¤È¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡¥¥°¥ë¡¼¥×¥ª¥×¥·¥ç¥ó¤Ï¡¤´ðËÜŪ¤Ëɸ½àŪ¤Ê¥ª¥×¥·¥ç ¥ó¤Î¹½Ê¸¤ÈƱ¤¸¤Ç¤¹¤¬¡¤É¬¿Ü¥Õ¥é¥°¤ò»ØÄꤷ¤Æ¤Ï¤Ê¤é¤º(Ʊ¤¸¥°¥ë¡¼¥×¤Î¥ª¥×¥·¥ç ¥ó¤Ï¡¤¤ª¸ß¤¤¤ËÇÓ¾Ū¤Ê¤Î¤Ç¡¤°ÕÌ£¤¬Ìµ¤¤¤Ç¤·¤ç¤¦)¡¤¥ª¥×¥·¥ç¥ó¤¬½ê°¤¹¤ë¥° ¥ë¡¼¥×¤ò»ØÄꤹ¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡¥

defgroup "<group name>" {groupdesc="<group description>"} {yes}
groupoption <long> <short> <desc> <argtype> group="<group name>" \
     {argoptional} {multiple}

¥°¥ë¡¼¥×¤¬É¬¿Ü¤È¤·¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¤¥°¥ë¡¼¥×¤Ë½ê°¤·¤Æ¤¤¤ë°ì¤Ä¤Î(¤½ ¤·¤Æ¡¤°ì¤Ä¤À¤±)¥ª¥×¥·¥ç¥ó¤ò»ØÄꤹ¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡¥

°Ê²¼¤ÏÎã¤Ç¤¹(¥Æ¥¹¥Ètest_group_cmd.ggo¤«¤é»ý¤Ã¤Æ¤­¤Þ¤·¤¿)¡¥

defgroup "my grp2"
defgroup "grp1" groupdesc="an option of this group is required" yes
groupoption "opta" a "string a" group="grp1" multiple
groupoption "optA" A "string A" string group="grp1" argoptional
groupoption "optAmul" M "string M" string group="grp1" argoptional multiple
groupoption "optb" b "string b" group="grp1"
groupoption "optc" - "string c" group="my grp2"
groupoption "optd" d "string d" group="my grp2"

¥°¥ë¡¼¥×grp1¤Ïɬ¿Ü¤Ç¡¤--opta¤Þ¤¿¤Ï--optb¤ò»ØÄꤹ¤ë ɬÍפ¬¤¢¤ê¤Þ¤¹(¤½¤·¤Æ¤½¤ì¤Ï¡¤¤É¤Á¤é¤«°ìÊý¤À¤±¤Ç¤¹)¡¥°Ê²¼¤Ï²¿ÅÙ¤«¼Â¹Ô¤· ¤¿·ë²Ì¤Ç¤¹¡¥

$ ./test_groups
test_groups: 0 options of group grp1 were given. One is required
$ ./test_groups -a          OK
$ ./test_groups -a -a       OK (the same option given twice)
$ ./test_groups -a -b
test_groups: 2 options of group grp1 were given. One is required
$ ./test_groups -a -c       OK
$ ./test_groups -a --optc -d
test_groups: 2 options of group my grp2 were given. At most one is required