Automatically create tito's console script

Create tito.cli.main() which serves as command line's entry point that
can be used:
- by setuptools' 'console_scripts' entry point mechanism for automatic
  script creation,
- via 'if __name__ == "__main__":'.

Remove pre-generated bin/tito script.

Update SPEC file.
This commit is contained in:
Tadej Janež 2017-02-01 14:03:30 +01:00
parent 805ce9ca4a
commit 9820841af5
No known key found for this signature in database
GPG key ID: 37B064855C101C1B
4 changed files with 19 additions and 27 deletions

View file

@ -1,25 +0,0 @@
#!/usr/bin/python
#
# Copyright (c) 2008,2009 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#
import sys
from tito.cli import CLI
if __name__ == "__main__":
try:
CLI().main(sys.argv[1:])
except KeyboardInterrupt:
pass

View file

@ -37,9 +37,15 @@ setup(
'blessed'
],
# automatically create console scripts
entry_points={
'console_scripts': [
'tito = tito.cli:main',
],
},
# non-python scripts go here
scripts=[
'bin/tito',
'bin/generate-patches.pl'
],

View file

@ -887,3 +887,15 @@ CLI_MODULES = {
"report": ReportModule,
"init": InitModule,
}
def main():
"""Command line's entry point."""
try:
CLI().main(sys.argv[1:])
except KeyboardInterrupt:
pass
if __name__ == "__main__":
main()

View file

@ -80,7 +80,6 @@ git.
%prep
%setup -q -n tito-%{version}
sed -i 1"s|#!.*|#!%{ourpythonbin}|" bin/tito
%build
%{ourpythonbin} setup.py build