George Keishing | e7e9171 | 2021-09-03 11:28:44 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 2 | |
Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 3 | from gen_arg import * |
Patrick Williams | 5731818 | 2022-12-08 06:18:26 -0600 | [diff] [blame^] | 4 | from gen_print import * |
Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 5 | from gen_valid import * |
Michael Walsh | 2d8d7f3 | 2018-06-01 15:21:09 -0500 | [diff] [blame] | 6 | |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 7 | parser = argparse.ArgumentParser( |
Patrick Williams | 5731818 | 2022-12-08 06:18:26 -0600 | [diff] [blame^] | 8 | usage="%(prog)s [OPTIONS]", |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 9 | description="%(prog)s will...", |
Michael Walsh | d0741f8 | 2017-12-21 14:04:21 -0600 | [diff] [blame] | 10 | formatter_class=argparse.ArgumentDefaultsHelpFormatter, |
Patrick Williams | 5731818 | 2022-12-08 06:18:26 -0600 | [diff] [blame^] | 11 | prefix_chars="-+", |
| 12 | ) |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 13 | |
Patrick Williams | 5731818 | 2022-12-08 06:18:26 -0600 | [diff] [blame^] | 14 | parser.add_argument("--whatever", default="", help="bla, bla.") |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 15 | |
Michael Walsh | 41dda1b | 2017-09-14 11:42:29 -0500 | [diff] [blame] | 16 | # Populate stock_list with options we want. |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 17 | stock_list = [("test_mode", 0), ("quiet", 0), ("debug", 0)] |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 18 | |
| 19 | |
Michael Walsh | ee24ff5 | 2019-12-13 14:42:59 -0600 | [diff] [blame] | 20 | def exit_function(): |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 21 | r""" |
Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 22 | Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT). This |
| 23 | function will be called by gen_exit_function(). |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 24 | """ |
| 25 | |
Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 26 | # If you have no cleanup to do, you can delete this function altogether. |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 27 | |
| 28 | # Your cleanup code here. |
| 29 | |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 30 | |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 31 | def validate_parms(): |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 32 | r""" |
Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 33 | Validate program parameters, etc. This function will be called by gen_setup(). |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 34 | """ |
| 35 | |
Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 36 | # If you have no validation to do, you can delete this function altogether. |
Michael Walsh | 6607a28 | 2019-09-13 14:21:01 -0500 | [diff] [blame] | 37 | |
Michael Walsh | 2d8d7f3 | 2018-06-01 15:21:09 -0500 | [diff] [blame] | 38 | # Your validation code here... |
| 39 | # valid_value(whatever) |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 40 | |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 41 | |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 42 | def main(): |
Michael Walsh | 6607a28 | 2019-09-13 14:21:01 -0500 | [diff] [blame] | 43 | gen_setup() |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 44 | |
| 45 | # Your code here. |
| 46 | |
Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 47 | |
Michael Walsh | 2d8d7f3 | 2018-06-01 15:21:09 -0500 | [diff] [blame] | 48 | main() |