---
 cli/copr             | 25 +++++++++++++++++++++++++
 cli/copr_cli/main.py |  9 ++++++---
 2 files changed, 31 insertions(+), 3 deletions(-)
 create mode 100755 cli/copr

diff --git a/cli/copr b/cli/copr
new file mode 100755
index 0000000..a119b23
--- /dev/null
+++ b/cli/copr
@@ -0,0 +1,25 @@
+#! /bin/sh
+
+# Run copr-cli script directly from git.
+# Copyright (C) 2015 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+absdir="$(dirname "$(readlink -f "$0")")"
+cd "$absdir"
+
+export PYTHONPATH="$absdir/../python"
+
+python -m copr_cli.main "$@"
diff --git a/cli/copr_cli/main.py b/cli/copr_cli/main.py
index 8d55466..6dc8b9f 100644
--- a/cli/copr_cli/main.py
+++ b/cli/copr_cli/main.py
@@ -40,10 +40,10 @@ no_config_warning = """
 
 
 class Commands(object):
-    def __init__(self):
+    def __init__(self, config):
 
         try:
-            self.client = CoprClient.create_from_file_config()
+            self.client = CoprClient.create_from_file_config(config)
         except (copr_exceptions.CoprNoConfException,
                 copr_exceptions.CoprConfigException):
             print(no_config_warning)
@@ -295,6 +295,9 @@ def setup_parser():
     parser.add_argument("--debug", dest="debug", action="store_true",
                         help="Enable debug output")
 
+    parser.add_argument("--config", dest="config",
+                        help="Path to an alternative configuration file")
+
     subparsers = parser.add_subparsers(title="actions")
 
     # create the parser for the "list" command
@@ -422,7 +425,7 @@ def main(argv=sys.argv[1:]):
         if arg.debug:
             enable_debug()
 
-        commands = Commands()
+        commands = Commands(arg.config)
         getattr(commands, arg.func)(arg)
 
     except KeyboardInterrupt:
-- 
2.5.0
_______________________________________________
copr-devel mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to