parse_options() -> opts, args Parse any command-line options given returning both the parsed options and arguments.
()
| 132 | print "%d. %s" % (i, url) |
| 133 | |
| 134 | def parse_options(): |
| 135 | """parse_options() -> opts, args |
| 136 | |
| 137 | Parse any command-line options given returning both |
| 138 | the parsed options and arguments. |
| 139 | """ |
| 140 | |
| 141 | parser = optparse.OptionParser(usage=USAGE, version=VERSION) |
| 142 | |
| 143 | parser.add_option("-q", "--quiet", |
| 144 | action="store_true", default=False, dest="quiet", |
| 145 | help="Enable quiet mode") |
| 146 | |
| 147 | parser.add_option("-l", "--links", |
| 148 | action="store_true", default=False, dest="links", |
| 149 | help="Get links for specified url only") |
| 150 | |
| 151 | parser.add_option("-d", "--depth", |
| 152 | action="store", type="int", default=30, dest="depth", |
| 153 | help="Maximum depth to traverse") |
| 154 | |
| 155 | opts, args = parser.parse_args() |
| 156 | |
| 157 | if len(args) < 1: |
| 158 | parser.print_help() |
| 159 | raise SystemExit, 1 |
| 160 | |
| 161 | return opts, args |
| 162 | |
| 163 | def main(): |
| 164 | opts, args = parse_options() |
no test coverage detected