Skip to content

Commit 30fb6f0

Browse files
committed
Added --version option
1 parent 5a2cda4 commit 30fb6f0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ pip install ijson
1717

1818
## Usage
1919
```
20-
usage: json2pcap.py [-h] [-i [INFILE]] -o OUTFILE [-p] [-m MASKED_FIELD] [-a ANONYMIZED_FIELD] [-s SALT] [-v]
20+
usage: json2pcap.py [-h] [--version] [-i [INFILE]] -o OUTFILE [-p] [-m MASKED_FIELD]
21+
[-a ANONYMIZED_FIELD] [-s SALT] [-v]
2122
22-
json2pcap v1.1
23+
json2pcap 1.1
2324
2425
Utility to generate pcap from json format.
2526
@@ -73,6 +74,7 @@ allowed values of the target field and field encoding.
7374
7475
optional arguments:
7576
-h, --help show this help message and exit
77+
--version show program's version number and exit
7678
-i [INFILE], --infile [INFILE]
7779
json generated by tshark -T json -x
7880
or by tshark -T jsonraw (not preserving frame timestamps).

json2pcap.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,10 @@ def generate_pcap(d):
473473
#
474474
# ************ MAIN **************
475475
#
476+
VERSION = "1.1"
477+
476478
parser = argparse.ArgumentParser(description="""
477-
json2pcap v1.1
479+
json2pcap {version}
478480
479481
Utility to generate pcap from json format.
480482
@@ -526,7 +528,8 @@ def generate_pcap(d):
526528
json2pcap is no performing correct protocol encoding with respect to
527529
allowed values of the target field and field encoding.
528530
529-
""", formatter_class=argparse.RawTextHelpFormatter)
531+
""".format(version=VERSION), formatter_class=argparse.RawTextHelpFormatter)
532+
parser.add_argument('--version', action='version', version='%(prog)s ' + VERSION)
530533
parser.add_argument('-i', '--infile', nargs='?', help='json generated by tshark -T json -x\nor by tshark -T jsonraw (not preserving frame timestamps).\nIf no inpout file is specified script reads from stdin.')
531534
parser.add_argument('-o', '--outfile', required=True, help='output pcap filename')
532535
parser.add_argument('-p', '--python', help='generate python payload instead of pcap (only 1st packet)', default=False, action='store_true')

0 commit comments

Comments
 (0)