smbclientng.core.ModuleArgumentParser
1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# File name : ModuleArgumentParser.py 4# Author : Podalirius (@podalirius_) 5# Date created : 23 may 2024 6 7 8import argparse 9import sys 10 11 12class ModuleArgumentParser(argparse.ArgumentParser): 13 """ 14 A custom argument parser for handling module-specific command-line arguments in the smbclientng application. 15 16 This class extends the argparse.ArgumentParser and provides custom error handling specific to the needs of smbclientng modules. 17 It is designed to provide clear and user-friendly command-line interfaces for various modules within the smbclientng suite. 18 19 Attributes: 20 None 21 22 Methods: 23 error(message: str): 24 Overrides the default error handling to provide a more informative error message and display the help text. 25 """ 26 27 exit_on_error = False 28 29 def error(self, message): 30 """ 31 Overrides the default error handling of argparse.ArgumentParser to provide a custom error message and help display. 32 33 This method is called when ArgumentParser encounters an error. It writes the error message to stderr, 34 displays the help message, and then exits the program with a status code of 2. 35 36 Args: 37 message (str): The error message to be displayed. 38 """ 39 40 self.print_help() 41 sys.stderr.write('\n[!] Error: %s\n' % message)
13class ModuleArgumentParser(argparse.ArgumentParser): 14 """ 15 A custom argument parser for handling module-specific command-line arguments in the smbclientng application. 16 17 This class extends the argparse.ArgumentParser and provides custom error handling specific to the needs of smbclientng modules. 18 It is designed to provide clear and user-friendly command-line interfaces for various modules within the smbclientng suite. 19 20 Attributes: 21 None 22 23 Methods: 24 error(message: str): 25 Overrides the default error handling to provide a more informative error message and display the help text. 26 """ 27 28 exit_on_error = False 29 30 def error(self, message): 31 """ 32 Overrides the default error handling of argparse.ArgumentParser to provide a custom error message and help display. 33 34 This method is called when ArgumentParser encounters an error. It writes the error message to stderr, 35 displays the help message, and then exits the program with a status code of 2. 36 37 Args: 38 message (str): The error message to be displayed. 39 """ 40 41 self.print_help() 42 sys.stderr.write('\n[!] Error: %s\n' % message)
A custom argument parser for handling module-specific command-line arguments in the smbclientng application.
This class extends the argparse.ArgumentParser and provides custom error handling specific to the needs of smbclientng modules. It is designed to provide clear and user-friendly command-line interfaces for various modules within the smbclientng suite.
Attributes: None
Methods: error(message: str): Overrides the default error handling to provide a more informative error message and display the help text.
30 def error(self, message): 31 """ 32 Overrides the default error handling of argparse.ArgumentParser to provide a custom error message and help display. 33 34 This method is called when ArgumentParser encounters an error. It writes the error message to stderr, 35 displays the help message, and then exits the program with a status code of 2. 36 37 Args: 38 message (str): The error message to be displayed. 39 """ 40 41 self.print_help() 42 sys.stderr.write('\n[!] Error: %s\n' % message)
Overrides the default error handling of argparse.ArgumentParser to provide a custom error message and help display.
This method is called when ArgumentParser encounters an error. It writes the error message to stderr, displays the help message, and then exits the program with a status code of 2.
Args: message (str): The error message to be displayed.
Inherited Members
- argparse.ArgumentParser
- ArgumentParser
- prog
- usage
- epilog
- formatter_class
- fromfile_prefix_chars
- add_help
- allow_abbrev
- add_subparsers
- parse_args
- parse_known_args
- convert_arg_line_to_args
- parse_intermixed_args
- parse_known_intermixed_args
- format_usage
- format_help
- print_usage
- print_help
- exit
- argparse._ActionsContainer
- description
- argument_default
- prefix_chars
- conflict_handler
- register
- set_defaults
- get_default
- add_argument
- add_argument_group
- add_mutually_exclusive_group