|
Packit |
6bd9ab |
# coding: utf-8
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
# cmdline.py - functions for handling command-line options
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# Copyright (C) 2013-2017 Arthur de Jong
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# This library is free software; you can redistribute it and/or
|
|
Packit |
6bd9ab |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6bd9ab |
# License as published by the Free Software Foundation; either
|
|
Packit |
6bd9ab |
# version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# This library is distributed in the hope that it will be useful,
|
|
Packit |
6bd9ab |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6bd9ab |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6bd9ab |
# Lesser General Public License for more details.
|
|
Packit |
6bd9ab |
#
|
|
Packit |
6bd9ab |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6bd9ab |
# License along with this library; if not, write to the Free Software
|
|
Packit |
6bd9ab |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit |
6bd9ab |
# 02110-1301 USA
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
import argparse
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
import constants
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
version_string = '''
|
|
Packit |
6bd9ab |
%s
|
|
Packit |
6bd9ab |
Written by Arthur de Jong.
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
Copyright (C) 2013-2017 Arthur de Jong
|
|
Packit |
6bd9ab |
This is free software; see the source for copying conditions. There is NO
|
|
Packit |
6bd9ab |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
6bd9ab |
'''.strip() % constants.PACKAGE_STRING
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
class VersionAction(argparse.Action):
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
def __init__(self, option_strings, dest,
|
|
Packit |
6bd9ab |
help='output version information and exit'):
|
|
Packit |
6bd9ab |
super(VersionAction, self).__init__(
|
|
Packit |
6bd9ab |
option_strings=option_strings,
|
|
Packit |
6bd9ab |
dest=argparse.SUPPRESS,
|
|
Packit |
6bd9ab |
default=argparse.SUPPRESS,
|
|
Packit |
6bd9ab |
nargs=0,
|
|
Packit |
6bd9ab |
help=help)
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
def __call__(self, parser, namespace, values, option_string=None):
|
|
Packit |
6bd9ab |
print(version_string)
|
|
Packit |
6bd9ab |
parser.exit()
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
class ListShellsAction(argparse.Action):
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
def __init__(self, option_strings, dest,
|
|
Packit |
6bd9ab |
help='list the shells found in /etc/shells'):
|
|
Packit |
6bd9ab |
super(ListShellsAction, self).__init__(
|
|
Packit |
6bd9ab |
option_strings=option_strings,
|
|
Packit |
6bd9ab |
dest=argparse.SUPPRESS,
|
|
Packit |
6bd9ab |
default=argparse.SUPPRESS,
|
|
Packit |
6bd9ab |
nargs=0,
|
|
Packit |
6bd9ab |
help=help)
|
|
Packit |
6bd9ab |
|
|
Packit |
6bd9ab |
def __call__(self, parser, namespace, values, option_string=None):
|
|
Packit |
6bd9ab |
import shells
|
|
Packit |
6bd9ab |
for shell in shells.list_shells():
|
|
Packit |
6bd9ab |
print(shell)
|
|
Packit |
6bd9ab |
parser.exit()
|