This simplifies running the copr client against other than default
(https://copr.fedoraproject.org) Copr service.
---
 cli/copr                    | 22 ++++++++++++++++++++++
 cli/copr_cli/main.py        |  9 ++++++---
 cli/man/copr-cli.1.asciidoc | 24 +++++++++++++-----------
 3 files changed, 41 insertions(+), 14 deletions(-)
 create mode 100755 cli/copr

diff --git a/cli/copr b/cli/copr
new file mode 100755
index 0000000..157fb10
--- /dev/null
+++ b/cli/copr
@@ -0,0 +1,22 @@
+#! /bin/sh
+
+# Run copr-cli script directly from git.
+# Copyright (C) 2016 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")")"
+export PYTHONPATH="$absdir:$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:
diff --git a/cli/man/copr-cli.1.asciidoc b/cli/man/copr-cli.1.asciidoc
index e173f84..c797453 100644
--- a/cli/man/copr-cli.1.asciidoc
+++ b/cli/man/copr-cli.1.asciidoc
@@ -10,7 +10,7 @@ copr-cli - command line interface for the Copr service
 
 SYNOPSIS
 --------
-copr-cli [-h] [--version] {list,create,build} ...
+copr-cli [-h] [--version] [--config CONFIG] {list,create,build} ...
 
 DESCRIPTION
 -----------
@@ -28,6 +28,9 @@ show this help message and exit
 --version::
 show the program's version number and exit
 
+--config::
+path to an alternative configuration file (default is ~/.config/copr).
+
 ACTIONS
 -------
 
@@ -175,24 +178,23 @@ format:
  username = msuchy
  login = Y57wcg==##fkfaxbkjhuoiebfafadl
  token = vbfseelqdebzedukgombekmuvbkqwo
+ copr_url = https://copr.fedoraproject.org
 
 Be aware that API tokens have an expiration date. The expiration date for
 your token is listed on the /api page.
 
-If you are using a different instance for the Copr service, the API token is
-available from http://your.copr.server/api/
+USING DIFFERENT COPR INSTANCE
+-----------------------------
 
-COPR URL
---------
+If you plan to run `copr` client against non-default Copr instance, the API
+token is available on the http://YOUR.COPR.URL/api/ page.  You can either
+replace your default `~/.config/copr` configuration file, or rather use
+alternative file with a shell alias
 
-You can alternatively specify a different URL for the Copr service.
-Open the file `~/.config/copr` provide the `copr_url` setting:
+    alias your_copr='copr --config ~/.config/your-copr'
 
- [copr-cli]
- copr_url = https://copr.fedoraproject.org
+inserted into your profile.
 
-The value listed above is the default value. Only define copr_url only if
-you use a different instance.
 
 AUTHORS
 -------
-- 
2.5.0
_______________________________________________
copr-devel mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to