Anonymous avatar Anonymous committed 36c10b7

Support multiple profiles in config file.

Option '--profile' can be used to choose from which config file section
smart-live-rebuild will use config.

Comments (0)

Files changed (2)

 The path to that file can be specified as '--config-file' (or '-c'), and
 the default one is '~/.config/smart-live-rebuild.conf'.
 
-The configuration file has a format similar to Windows .ini files, where all
-the options need to be in '[smart-live-rebuild]' section. The keys for respe-
-ctive options match the command-line argument names, with 'no-' prefix stripped
-and all dashes ('-') changed into underscores ('_').
+The configuration file has a format similar to Windows .ini files. Sections
+correspond to available profiles, with '[smart-live-rebuild]' being the default
+one (other can be specified using '--profile'/'-p'). The keys for respective
+options match the command-line argument names, with 'no-' prefix stripped
+and all dashes ('-') replaced with underscores ('_').
 
 The values for boolean types can be specified in any way suitable for
 ConfigParser python class (i.e. true/false/yes/no/on/off). The 'type' list

smart-live-rebuild.py

 		help='Disable setting ESCM_OFFLINE for emerge.')
 	opt.add_option('-p', '--pretend', action='store_true', dest='pretend',
 		help='Only print a list of the packages which were updated; do not call emerge to rebuild them.')
+	opt.add_option('-P', '--profile', action='store', dest='profile',
+		help='Configuration profile (config file section) to use (default: smart-live-rebuild)')
 	opt.add_option('-Q', '--quickpkg', action='store_true', dest='quickpkg',
 		help='Call quickpkg to create binary backups of packages which are going to be updated.')
 	opt.add_option('-S', '--no-setuid', action='store_false', dest='setuid',
 		'unprivileged_user': 'False'
 	}
 
-	opt.set_defaults(config_file = '~/.config/smart-live-rebuild.conf')
+	opt.set_defaults(
+			config_file = '~/.config/smart-live-rebuild.conf',
+			profile = 'smart-live-rebuild'
+	)
 	c = ConfigParser(defs)
 	(opts, args) = opt.parse_args(argv[1:])
 
 	# now look for the config file(s)
 	cfl = [opts.config_file]
-	sect = 'smart-live-rebuild'
+	sect = opts.profile
 	try:
 		while cfl[-1] != '' and c.read(os.path.expanduser(cfl[-1])):
 			# config file chaining support
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.