commit 7f9918d9b16b4e9211bc1df066208d4eda0f8b14
parent 37e662d5052ee74185f8e0a86dd51850d81fc496
Author: Frederic Cambus <fred@statdns.com>
Date: Wed, 24 Feb 2021 12:19:48 +0100
Add a -h switch to display usage information.
Diffstat:
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/dnc.1 b/dnc.1
@@ -24,7 +24,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: February 8 2021 $
+.Dd $Mdocdate: February 24 2021 $
.Dt DNC 1
.Os
.Sh NAME
@@ -40,6 +40,8 @@ dnc (Domain Name Checker), is a CLI tool to check domain names configuration.
.Pp
The options are as follows:
.Bl -tag -width 10n
+.It Fl h
+Display usage.
.It Fl v
Display version.
.El
diff --git a/dnc.py b/dnc.py
@@ -6,7 +6,7 @@
# https://github.com/fcambus/dnc
#
# Created: 2014-02-11
-# Last Updated: 2021-01-19
+# Last Updated: 2021-02-24
#
# dnc is released under the BSD 2-Clause license.
# See LICENSE file for details.
@@ -23,6 +23,11 @@ from prettytable import PrettyTable
socket.setdefaulttimeout(1)
+def usage():
+ print("dnc [-hv] domain\n\n" \
+ "The options are as follows:\n\n" \
+ " -h Display usage.\n" \
+ " -v Display version.")
def query(domain: str, rrtype: str) -> str:
try:
@@ -52,7 +57,7 @@ def main():
actions = []
try:
- options, args = getopt.getopt(sys.argv[1:], "46mnsv")
+ options, args = getopt.getopt(sys.argv[1:], "46hmnsv")
except getopt.GetoptError as err:
print(err)
sys.exit(1)
@@ -64,6 +69,9 @@ def main():
if option == "-6":
header.append("IPv6")
actions.append((query, "AAAA"))
+ if option == "-h":
+ usage()
+ sys.exit(0)
if option == "-m":
header.append("MX")
actions.append((query, "MX"))