lucocozz /
Argus
Argus is a cross-platform modern feature-rich command-line argument parser for C
Loading repository data…
igormironchik / repository
args-parser is a small C++ header-only library for parsing command line arguments.
This is args-parser.
args-parser is a small C++ header-only library for parsing command line arguments.
args-parser to my project?args-parser provide bindings of variables to arguments?--argument.-b.--argument value and --argument=value.-abc defines three flags -a, -b and -c.-abc=value. And here, flag -c will have the value value.MultiArg class provides the ability to define more than one value for an argument. These types
of arguments can be specified more than once in the command line. And the resulted value
of the argument will be StringList.Command class can be used to define command in command line interface.
Command is the argument without dash/dashes at the beginning, add for example.Command can has children arguments or even subcommands.args-parser groups can be used to group arguments into groups to check their
definitions after parsing, so if constraint of group will be violated
exception will be thrown.args-parser provides Help argument that provides help printing. Help
uses -h, --help arguments. Help can receive value with name
of argument or command to print help about. If Help receives the name
of a command as the value, then the name of a subcommand or a child argument
can also be provided as the next value, to get help about the subcommand/child argument.args-parser don't know about argument in command line interface it provides
information about possible arguments if some misspelling was in command
line interface. If args-parser can't assume anything about entered argument it
will just say about unknown argument through the exception and parsing will
fail.CmdLine::HandlePositionalArguments option provided to CmdLine
constructor, args-parser will handle positional arguments, these are such arguments
that can't be parsed with provided arguments, flags, commands and stay at the end
of the command line. Be careful with combining MultiArg and positional arguments,
because MultiArg can eat almost everything that is not a valid argument.Since version 4.0.0 args-parser can be built with different strings - std::string,
std::wstring and QString.
args-parser with std::wstring support define ARGS_WSTRING_BUILDargs-parser with QString support define ARGS_QSTRING_BUILDargs-parser will be build with std::string.args-parser extensively uses list of string in internal structures and to return
values of arguments outside. In the code this is StringList
type defined in args-parser/types.hpp. By default underlying type is
std::vector or QVector when building with Qt that can be changed
to std::list, QLinkedList or std::deque, QList.
ARGS_LIST to build args-parser with std::list, QLinkedList
as StringListARGS_DEQUE to build args-parser with std::deque, QList
as StringListargs-parser to my project?The simplest way is just copy args-parser directory with headers to any location in
your project. With CMake you can clone entire args-parser project somewhere in your
project and just do add_subdirectory(), if you will do so you have to
add include directory path to your project with
include_directories( ${args-parser_INCLUDE_DIRECTORIES} ).
You can clone/download args-parser, build and install it with CMake. In this
case it will be possible to use find_package( args-parser ) in CMakeLists.txt of
your project.
You can use Conan package manager.
There are tons of libraries for parsing command line arguments on the
Internet. But args-parser also provides the possibility to define commands, like
git add -A
git commit
git push
Help output is very user-friendly.
If you need only simple arguments in style --do-it <value> then possibly
you will find another library more useful for you, but who knows...
For those, who use old style syntax the answer should be on the plate, as developer
can look at the code of Help class, that implements help argument. But for those, who
prefer one-line syntax the answer can be not so evident, but it's so too. It doesn't matter
what syntax you use, new (one-line) syntax is just a wrapper for old one. I.e. line:
cmd.addHelp( true, argv[ 0 ],
"This application just show power of the Args help." );
Is just a wrapper around of Help class. For printing help args-parser uses
HelpPrinter class. So developer can use it for printing help in some rare cases,
as:
HelpPrinter printer;
printer.setExecutable( argv[ 0 ] );
printer.setAppDescription( "This application just show power of the Args help." );
printer.setLineLength( length );
printer.setCmdLine( cmd );
printer.print( outStream() );
args-parser provide bindings of variables to arguments?args-parser provide validators? It's the same.
I decided that this aspect is very application specific. There is no need for such library
to do any conversions of arguments' values, to bind them to some variables. This will
do API very complex only. I know what you will say: this is very nice feature, it helps...
Really? How often and how much it helped you? Arguments parser should handle the string
that user provided to the application, it should separate arguments, commands, values,
store it in internal state of parser, and allow to developer just write some if
operators to choose branch of the program logic. What will give you, as to developer,
if values will be bind to concrete variables? Will not you write the same code with if
operators? So why I should do the library more complex?I found only one library at GitHub that can compete with args-parser, and this is
CLI11. And here is the question of the taste more.
But CLI11 can handle commands as usual arguments, it's doesn't matter how much times
they present in command line, whereas args-parser handles commands as commands. Theirs
approach possibly more flexible, but when I designed args-parser I thought on commands
as on some action to do in application's logic, whereas arguments are for data. I can do
the same, but is it needed?
CLI11 has possibility to set formatter of the help, args-parser allow to set
custom HelpPrinterIface on the Help argument. But who and when will do it?
And I believe that help in args-parser is a little better than in CLI11.
CLI11 works more with callbacks, whereas args-parser uses hierarchy of
classes with polymorphism. In args-parser you can inherit from any argument's
class, override methods you need and receive something very application specific.
And again, this is more question of taste.
Uh, oh, I found one more interesting arguments parsing library, This is
Taywee/Args. Guys, this is a question of taste.
And, as said in CLI11 documentation about Taywee/Args, args-parser as
CLI11 less verbose. Taywee/Args has benchmark to compare performance with
TCLAP and boost::program_options., I want to say that args-parser 2 times
faster than Taywee/Args, dry numbers says that Tyawee/Args runs 0.635314
second, whereas args-parser runs 0.346813 second.
What I want to say about minuses of args-parseris that I don't support other
delimiter characters than - for flags and -- for arguments.
| Version | Changes |
|---|---|
| 6.3.6 | Added possibility for more chain cases. Fixed minor issue in one-line syntax API. |
| 6.3.5 | Added printing of default value in the help. Added possibility to split description by paragraphs with \n in the description. Too long words in the help splits now if they don't fit in. |
| 6.3.4 | Fixed issue with MSVC when globally defined ::Command class was detected as friend of ArgIface instead of Args::Command |
| 6.3.3 | Minor fix for compilation with -Werror=shadow |
| 6.3.2 | Fixed multiple definitions when included from different compile units. |
| 6.3.1 | Improved performance. Added possibility to set positional arguments string for the help. Added benchmark. |
| 6.3.0 | Added possibility to handle positional arguments. |
| 6.2.0.1 | Ready for use with Qt6. |
| 6.2.0.0 | Allowed to inherit from some classes. Added addArg() methods into API. |
| 6.1.1.1 | Added possibility to set up custom help printer in help argument. |
| 6.1.1.0 | Improved API with new syntax, now it's impossible to mess with end() methods. Fixed issue with printing help of global argument under command. |
| 6.1.0.0 | Added possibility to add Command into groups. |
| 6.0.0.0 | In this version was removed ArgAsCommand class, and was added fully-featured support for sub-commands, that can be created with Command class, i.e. Command can has Command as child. So it's possible to create such CLI as git submodule update --init --recursive. |
First of all you must know that practically all classes of the args-parser throws exceptions on errors
and there is one specific exceptions that inform you about that that help was shown. This specific
exception (HelpHasBeenPrintedException) is needed for processing program's logic that usually stops
execution at this point.
Since version 5.0.0 args-parser provides two API: the old one and auxiliary API
that allows to define arguments in one line of code. Let's look.
// args-parser include.
#include <args-parser/all.hpp>
using namespace Args;
int main( int argc, char ** argv )
{
try {
CmdLine cmd( argc, argv, CmdLin
Selected from shared topics, language and repository description—not editorial ratings.
lucocozz /
Argus is a cross-platform modern feature-rich command-line argument parser for C
UsboKirishima /
Wimey is a lightweight C library for building command-line tools with ease. It supports both command and argument parsing, including value handling, automatic help generation, and type-safe conversions. Designed for flexibility and minimal dependencies, Wimey helps you structure your CLI programs cleanly and efficiently.
MrGit123 /
#!/usr/bin/python3 # Code by PosiX from urllib.request import Request, urlopen from urllib.error import URLError, HTTPError import argparse import sys import time global starttime class ZeroScann(): def __init__(self): self.scan() def scan(self): # argument parser like shit parser = argparse.ArgumentParser(prog="PosiX.py", description="Simple Find Shell in Website") parser.add_argument("-u", dest="domain", help="your url") parser.add_argument("-w", dest="wordlist", help="your wordlsit") args = parser.parse_args() if not args.domain: sys.exit("\033[36musage: shell.py -u example.com -w wordlist.txt") if not args.wordlist: sys.exit("\033[36musage: shell.py -u example.com -w wordlist.txt") # handle url website format site = args.domain print("\033[96m[?] \033[0mStart Crawling...") print("\033[96m[!] \033[0mWait a sec!","\n") time.sleep(3) if not site.startswith("http://"): site = "http://"+site if not site.endswith("/"): site = site+"/" # load wordlist try: pathlist = args.wordlist wlist = open(pathlist, "r") wordlist = wlist.readlines() except FileNotFound as e: print("\033[91mUpss, Wordlist Not Found!\033[0m") exit() finally: try: wlist.close() except: print("\033[91mWordlist Can\'t Close!\033[0m") # user-agent user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36" #list to hold the results we find found = [] # respon code resp_codes = {403 : "403 forbidden", 401 : "401 unauthorized"} # loop with join pathlist starttime = time.time() for psx in wordlist: try: psx = psx.replace("\n", "") url = site+psx req = Request(url, headers={"User-Agent": user_agent}) time.sleep(0.1) try: connection = urlopen(req) print("\033[96m[\033[90m{0}\033[96m]".format(time.strftime("%H:%M:%S")),"\033[92mfound:","\033[0m/"+psx) found.append(url) except HTTPError as e: if e.code == 404: print("\033[96m[\033[90m{0}\033[96m]".format(time.strftime("%H:%M:%S")),"\033[91merror:","\033[0m/"+psx) else: print("\033[96m[\033[90m{0}\033[96m]".format(time.strftime("%H:%M:%S")),"\033[92minfo :","\033[33m/"+psx,"\033[92mstatus:\033[33m",resp_codes[e.code]) except URLError as e: sys.exit("\033[31m[!] Upss, No Internet Connection") except Exception as er: print("\n\033[93m[?] \033[0mYour Connection Is Bad") print("\033[93m[!] \033[0mExit Program") time.sleep(3) exit() except KeyboardInterrupt as e: print("\n\033[96m[?] \033[0mCTRL+C Detected") print("\033[96m[!] \033[0mExit Program") time.sleep(2) exit() if found: print("\n\033[96m[+] \033[0mResult Found\033[92m") print("\n".join(found)) print("\033[96m[?] \033[0mTime Elasped: \033[35m%.2f\033[0m Seconds" % float(time.time()-starttime)) else: print("\n\033[96m[!] \033[0mCould Not Find Any Shell Backdoor") print("\033[96m[?] \033[0mTime Elasped: \033[33m%.2f\033[0m Seconds" % float(time.time()-starttime)) def banner(): # just the screen display like this info = """\033[33m ___ .' '. : : | _ _ | .-.|(\033[91m0\033[93m)_(\033[91m0\033[93m)|.-. ( ( | .--. | ) ) '-/ ( ) \-' / '--' \\ \ `\033[91m"===="\033[93m` / '\ /' '\ /' _/'-.-'\_ _..:;\._/v\_./:;.._ .'/;:;:;\ /^\ /;:;:;\\'. / /;:;:;:;\| |/:;:;:;:\ \\ / /;:;:;:;:;\_/:;:;:;:;:\ \\ \033[91m # ================================== # # Shell Scanner # # Code by PosiX #\033[0m # Twitter: @posiX # # http://maqlo-heker.blogspot.com # # ================================== # """ return info print(banner()) if __name__ == '__main__': ZeroScann()
jassim666 /
@@ -0,0 +1,185 @@ #!/usr/bin/env python """ Make the antismash output actually useful """ __author__ = "Matt Olm" __version__ = "0.1.0" __license__ = "MIT" import argparse import glob import os import textwrap import pandas as pd from Bio import SeqIO def main(args): """ Main entry point of the app """ if not os.path.exists(args.out): os.makedirs(args.out) if not os.path.exists(args.smash): print('{0} is not an antismash directory- quitting'.format(args.smash)) parse_antismash_folder(args.smash, args.out) def parse_antismash_folder(folder, outdir, write=True): ''' Take an antismash folder and parse it to make useful output ''' gene_clusters_loc = os.path.join(folder, 'geneclusters.txt') ass_name = os.path.join(folder).split('/')[-2] # Parse geneclusters.txt if not os.path.isfile(gene_clusters_loc): print("{0} is empty!!!!! Returning nothing".format(\ folder)) return if os.stat(gene_clusters_loc).st_size == 0: print("{0} has an empty geneclusters- returning nothing".format(\ folder)) return gdb = load_geneclusters_txt(gene_clusters_loc, ass_name) # Load genbank file full_gb = glob.glob(os.path.join(folder, '*.final.gbk')) assert len(full_gb) == 1 full_gb = full_gb[0] # Save geneclusters info gdb.to_csv(os.path.join(outdir, '{0}.geneclusters.txt'.format(ass_name)),\ index=False, sep='\t') # Write fasta files Sdb = write_fasta_files(gdb, full_gb, outdir, write=True) return gdb, Sdb def load_geneclusters_txt(file, ass_name): ''' parse geneclusters file and return dataframe ''' gdb = pd.read_table(file, header=None) cols = ['contig_full', 'scaffold_full', 'cluster_type', \ 'cluster_genes', 'cluster_genes_again'] gdb.columns = cols for c in ['cluster_genes', 'cluster_genes_again']: gdb[c] = [list(x.split(';')) for x in gdb[c]] gdb['contig'] = [x.split('_')[0] for x in gdb['contig_full']] gdb['scaffold'] = [x.split(' ')[0] for x in gdb['scaffold_full']] gdb.insert(0, 'cluster_number', range(1, len(gdb) + 1)) # Make sure there are no double clusters assert len(gdb[gdb['cluster_number'].duplicated()]) == 0 # Make sure cluster types are the same assert len(gdb[gdb['cluster_genes'] != gdb['cluster_genes_again']]) == 0 # Make sure all clusters are continuous for l in gdb['cluster_genes'].tolist(): it = (int(x.split('_')[1]) for x in l if x.startswith('ctg')) first = next(it) assert all(a == b for a, b in enumerate(it, first + 1)) # Add assembly stuff gdb['assembly'] = ass_name gdb['cluster'] = ["cluster{1:03}".format(x, y) for x, y in zip(\ gdb['assembly'], gdb['cluster_number'])] del gdb['cluster_genes_again'] cols.remove('cluster_genes_again') return gdb[['cluster', 'contig', 'scaffold', 'assembly', 'cluster_number'] \ + cols] def write_fasta_files(xdb, gb_file, outdir, write=True): Sdb = pd.DataFrame() gdb = xdb.copy() for seq_record in SeqIO.parse(gb_file, "genbank"): if seq_record.id in list(gdb['contig_full']): # For every cluster on this scaffold: for cluster, db in gdb[gdb['contig_full'] == seq_record.id].groupby('cluster'): # Set up .fasta files fasta_base = os.path.join(outdir, "{0}_{1}".format(\ cluster, db['assembly'].tolist()[0])) fna_handle = open(fasta_base + '.fna', 'w') faa_handle = open(fasta_base + '.faa', 'w') # Set up info table table = {'cluster':[], 'gene':[], 'scaffold':[], 'location':[], 'info':[]} # Figure out genes to find to_find = db['cluster_genes'].tolist()[0] assert(len(to_find) > 0) # Print necessary genes to file for feature in seq_record.features: if feature.type != "CDS": continue # This gene needs to be printed if feature.qualifiers['locus_tag'][0] in to_find: gene = feature.qualifiers['locus_tag'][0] scaffold = db['scaffold'].tolist()[0] # mark gene as found to_find.remove(gene) # make gene header header = ">{0}__{1}__{2}".format(cluster, gene, scaffold) # write nucleotide fna_handle.write("{0}\n{1}\n".format(header, \ textwrap.fill(str(feature.location.extract(seq_record).seq), 80))) # write amino acid faa_handle.write("{0}\n{1}\n".format(header, \ textwrap.fill(str(feature.qualifiers['translation'][0]), 80))) # store information about gene table['cluster'].append(cluster) table['gene'].append(gene) table['location'].append(str(feature.location)) table['scaffold'].append(scaffold) if 'sec_met' in feature.qualifiers: table['info'].append(feature.qualifiers['sec_met']) else: table['info'].append('') # Close handles faa_handle.close() fna_handle.close() # Make sure all genes were found assert(len(to_find) == 0) # Save datatable sdb = pd.DataFrame(table) sdb.to_csv(fasta_base + '.info.tsv', sep='\t', index=False) # Append datatable Sdb = pd.concat([Sdb, sdb]) return Sdb if __name__ == "__main__": """ From the output of antismash, this will make parse it out in a nice way""" parser = argparse.ArgumentParser() # Required positional argument parser.add_argument("smash", help="location of antismash folder") parser.add_argument("out", help="location of output folder to store results") parser.add_argument( "--version", action="version", version="%(prog)s (version {version})".format(version=__version__)) args = parser.parse_args() main(args)