Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the name of the 'bugz' binary to choose the connection used #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion bin/bugz
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ from bugz.argparsers import make_parser
from bugz.cli import BugzError, PrettyBugz
from bugz.configfile import get_config

def program_name():
return os.path.basename(sys.argv[0])

def main():
parser = make_parser()

# parse options
args = parser.parse_args()
get_config(args)
get_config(program_name(), args)
if getattr(args, 'columns') is None:
setattr(args, 'columns', 0)

Expand Down
11 changes: 9 additions & 2 deletions bugz/configfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def fill_config(args, parser, section):
fill_config_option(args, parser, parser.get, section, 'encoding')
fill_config_option(args, parser, parser.getboolean, section, 'quiet')

def get_config(args):
def get_config(exe_name, args):
config_file = getattr(args, 'config_file')
if config_file is None:
config_file = DEFAULT_CONFIG_FILE
Expand Down Expand Up @@ -60,7 +60,14 @@ def get_config(args):
if "default" in sections:
fill_config(args, parser, "default")
if section is None:
section = config_option(parser, parser.get, "default", "connection")
# 'bugz-alias' handling
for i in sections:
bugz_alias = config_option(parser, parser.get, i, "bugz-alias")
if exe_name == bugz_alias:
section = i
break
else:
section = config_option(parser, parser.get, "default", "connection")

# parse a specific section
if section in sections:
Expand Down
9 changes: 9 additions & 0 deletions bugzrc.example
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
#
# quiet: True
#
# A "bugz alias" that allows the name of the 'bugz' binary to determine
# which connection to use.
# E.g. suppose you have a [gnome] section for http://bugzilla.gnome.org,
# Create a symblink to the 'bugz' binary named 'gnomebz'.
# Add "bugz-alias: gnomebz" to the [gnome] section then
# invoking "gnomebz" would work like "bugz --connection gnome".
#
# bugz-alias: gnomebz
#
# The special section named 'default' may also be used. Other sections will
# override any values specified here. The optional special key 'connection' is
# used to name the default connection, to use when no --connection parameter is
Expand Down