Improved config situation and module setup

This commit is contained in:
Daniel Dayley 2021-11-02 21:42:36 -06:00
parent 6357a60200
commit 3fa4d28040
2 changed files with 7 additions and 3 deletions

View File

@ -18,7 +18,7 @@ if __name__ == '__main__':
# Gather Argument options
EXAMPLE_TEXT='Example:\n\tpython-tool -h'
parser = argparse.ArgumentParser(epilog=EXAMPLE_TEXT,formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-c', '--config', action='store', help='Specify a config file (~/.config/python-tool.yml)',default='~/.config/python-tool.yml')
##config_parser.add_argument('-c', '--config', action='store', help='Specify a config file (~/.config/python-tool.yml)',default='~/.config/python-tool.yml')
parser.add_argument('-H', '--hosts', action='append', default=None, help='Collects arguments in an array.')
parser.add_argument('-d', '--dry-run', action='store_true', help='Store the existence of a variable.')
parser.add_argument('-l', '--log', action='store', help='Specify a file to log to.')

View File

@ -94,7 +94,8 @@ new_python_tool() {
done
if [ "$PYTHON_MODULE" == 'y' ]; then
mkdir ./"$NAME"/"$NAME"
touch ./"$NAME"/"$NAME"/__init__.py
# touch ./"$NAME"/"$NAME"/__init__.py
echo "from $NAME.$NAME import *" > ./"$NAME"/"$NAME"/__init__.py
touch ./"$NAME"/"$NAME"/"$NAME".py
PYTHON_TOOL_SETUP_INSTRUCTIONS+="Put your main classes and functionality in $NAME/$NAME.py and import/use that functionality in bin/$NAME"
else
@ -141,12 +142,15 @@ new_python_tool() {
# Configure package to install a default configuration file?
while [[ "$INSTALL_CONFIG" != 'y' && "$INSTALL_CONFIG" != "n" ]]; do
echo "Configure package to install a config file? (y/n)"
echo "Configure package to use and install a config file? (y/n)"
read INSTALL_CONFIG
done
if [ "$INSTALL_CONFIG" == 'y' ]; then
sed_i "s#INSTALL=\"\(.*\)\"#INSTALL=\"\1config \"#g" ./"$NAME"/setup.sh
sed_i "s/.*##config_\(parser.*\)/\1/g" ./"$NAME"/bin/"$NAME"
##config_parser
else
sed_i "s/.*##config_\(parser.*\)//g" ./"$NAME"/bin/"$NAME"
rm ./"$NAME"/config.yml
fi