# StoqArgs¶

## Overview¶

StoqArgs() contains the primary command line arguments for the stoQ Framework. All command line options made available in this function will be made avilable to plugins that are extended with this function.

Note

Command line arguments defined within StoqArgs() will be made available globally within the stoQ Framework. Plugin command line arguments must not be defined here, but should instead be defined within the plugin itself.

## Examples¶

From within a worker plugin, define command line arguments:

import sys
import argparse
from stoq.args import StoqArgs

# Instantiate our workers command line argument parser
parser = argparse.ArgumentParser()

# Initialize the default requirements for a worker, if needed.
parser = StoqArgs(parser)

# Define the argparse group for this plugin

# Define the command line arguments for the worker
dest='rulepath',
help="Path to rules file.")

# The first command line argument is reserved for the framework.
# The work should only parse everything after the first command
# line argument. We must always use stoQ's argv object to ensure
# the plugin is properly instantied whether it is imported or
# used via a command line script
options = parser.parse_args(self.stoq.argv[2:])

# If we need to handle command line argument, let's pass them
# to super().activate so they can be instantied within the worker
super().activate(options=options)


This will extend the command line arguments from those made available at initialization, to those defined in worker_opts. The variable rulepath, defined above, will be accessible by calling worker.rulepath

## API¶

stoq.args.StoqArgs(parser)

Initializes command line arguments within the plugin

Parameters: parser – argparse object for parsing Modified argparse object