Loading README +32 −24 Original line number Diff line number Diff line ====== Config ====== cc-cli support FreeDesktop BaseDirectory specifications (http://standards.freedesktop.org/basedir-spec/0.6/) Your main config is stored in ~/.config/cc-cli/cli (ini file format with section cli) You can configure all parameter in this file You will find an example in examples subdirectory in git. You can set default behaviour with environment variables. The following are recognised: CC_SERVER, CC_PORT, CC_LOGIN, CC_PASS, CC_DEBUG, CC_PROFILE To quickly connect to mulptiple servers, you can define profiles. A profile is an ini config file in ~/.config/cc-cli/ directory with suffix .profile and section profile. Profiles file are loaded exactly like the main config file. You can load toto profile by calling cc-cli -P toto You have to play with the following loading order to do worderful things. You configuration is loaded in this order: 1 load default config file settings 2 load default config file profile 2 load environment profile 3 load environment settings 4 load argline profile 5 load argline settings ======= Profile ======= A profile in a set of configuration options. cc-cli support FreeDesktop BaseDirectory specifications, see http://standards.freedesktop.org/basedir-spec/0.6/ to store his config files. Profiles are stored in ~/.config/cc-cli/profile. This file format is ini where every profile is a section. cc-cli load at every start the cli profile. You can specify a default profile in cli profile with option "profile". You will find examples in examples subdirectory in git repository. To quickly connect to mulptiple servers, you can define a profile by server. Profile is loaded in this order: 1 load [cli] profile in ~/.config/cc-cli/profile 2 load profile specified by option profile in [cli] profile 3 load profile specified by environment 4 load profile specified on argument line =========== Environment =========== You can set some options by environment variables. The following variables are recognised: CC_SERVER, CC_PORT, CC_LOGIN, CC_PASS, CC_DEBUG, CC_PROFILE. ===== Alias ===== CLI support aliasing. This is a very useful command substitution Alias is stored in ~/.config/cc-cli/alias You can use the alias command to set alias. Setting an alias w, which list online client Loading @@ -35,6 +38,11 @@ alias w "list a&con!=offline&role=client" Setting an alias vm, which list running vm (and show cpu) alias vm "list vm&status=running$cpu" ======= History ======= History is stored in ~/.local/share/cc-cli/history === TQL === Loading bin/cc-cli +18 −24 Original line number Diff line number Diff line Loading @@ -23,36 +23,28 @@ settings = { "port": "1984", "timeout": "30", "hsize": "100", "config": "%s/cli"%BaseDirectory.save_config_path(cccli.canonical_name), "alias": "%s/alias"%BaseDirectory.save_config_path(cccli.canonical_name), "history": "%s/history"%BaseDirectory.save_data_path(cccli.canonical_name), } def load_config_file(config, filename, section): '''Update a dict with param from an ini file ''' if os.access(filename, os.R_OK): fparser = ConfigParser.RawConfigParser() fparser.read(filename) if fparser.has_section(section): config.update(fparser.items(section)) else: printer.warn("Unable to load file %s"%filename) def get_profile_path(profile): '''Force a profile path from a profile name''' return "%s/%s/%s.profile"%(BaseDirectory.xdg_config_home, cccli.canonical_name, profile) try: # load a printer printer = Printer(False) # parse config file if os.access(settings["config"], os.R_OK): load_config_file(settings, settings["config"], "cli") # parse profile file and load default profile try: propath = "%s/profile"%BaseDirectory.save_config_path(cccli.canonical_name) fparser = ConfigParser.RawConfigParser() fparser.read(propath) if fparser.has_section("cli"): settings.update(fparser.items("cli")) except Exception: fparser = None # parse config file profile # load "default profile" profile if "profile" in settings: load_config_file(settings, get_profile_path(settings["profile"]), "profile") if fparser is not None and fparser.has_section(settings["profile"]): settings.update(fparser.items(settings["profile"])) del settings["profile"] # parse env Loading @@ -67,9 +59,10 @@ try: if "CC_DEBUG" in os.environ: settings["debug"] = "True" # parse env profile # load env profile if "CC_PROFILE" in os.environ: load_config_file(settings, get_profile_path(os.environ["CC_PROFILE"]), "profile") if fparser is not None and fparser.has_section(os.environ["CC_PROFILE"]): settings.update(fparser.items(os.environ["CC_PROFILE"])) # Parse line argument oparser = optparse.OptionParser(usage="usage: %prog [options] [commands]", Loading Loading @@ -99,9 +92,10 @@ try: if o: settings[i] = o # parse argline file profile # load argline profile if "profile" in settings: load_config_file(settings, get_profile_path(settings["profile"]), "profile") if fparser is not None and fparser.has_section(settings["profile"]): settings.update(fparser.items(settings["profile"])) del settings["profile"] # debug stuff Loading examples/clideleted 100644 → 0 +0 −4 Original line number Diff line number Diff line [cli] hsize = 1000 profile = lab examples/lab.profiledeleted 100644 → 0 +0 −5 Original line number Diff line number Diff line [profile] login = sluttrin pass = toto42sh server = 192.168.0.162 examples/millet.profiledeleted 100644 → 0 +0 −6 Original line number Diff line number Diff line [profile] login = seblu pass = iloveseblu server = 192.168.0.41 debug = true Loading
README +32 −24 Original line number Diff line number Diff line ====== Config ====== cc-cli support FreeDesktop BaseDirectory specifications (http://standards.freedesktop.org/basedir-spec/0.6/) Your main config is stored in ~/.config/cc-cli/cli (ini file format with section cli) You can configure all parameter in this file You will find an example in examples subdirectory in git. You can set default behaviour with environment variables. The following are recognised: CC_SERVER, CC_PORT, CC_LOGIN, CC_PASS, CC_DEBUG, CC_PROFILE To quickly connect to mulptiple servers, you can define profiles. A profile is an ini config file in ~/.config/cc-cli/ directory with suffix .profile and section profile. Profiles file are loaded exactly like the main config file. You can load toto profile by calling cc-cli -P toto You have to play with the following loading order to do worderful things. You configuration is loaded in this order: 1 load default config file settings 2 load default config file profile 2 load environment profile 3 load environment settings 4 load argline profile 5 load argline settings ======= Profile ======= A profile in a set of configuration options. cc-cli support FreeDesktop BaseDirectory specifications, see http://standards.freedesktop.org/basedir-spec/0.6/ to store his config files. Profiles are stored in ~/.config/cc-cli/profile. This file format is ini where every profile is a section. cc-cli load at every start the cli profile. You can specify a default profile in cli profile with option "profile". You will find examples in examples subdirectory in git repository. To quickly connect to mulptiple servers, you can define a profile by server. Profile is loaded in this order: 1 load [cli] profile in ~/.config/cc-cli/profile 2 load profile specified by option profile in [cli] profile 3 load profile specified by environment 4 load profile specified on argument line =========== Environment =========== You can set some options by environment variables. The following variables are recognised: CC_SERVER, CC_PORT, CC_LOGIN, CC_PASS, CC_DEBUG, CC_PROFILE. ===== Alias ===== CLI support aliasing. This is a very useful command substitution Alias is stored in ~/.config/cc-cli/alias You can use the alias command to set alias. Setting an alias w, which list online client Loading @@ -35,6 +38,11 @@ alias w "list a&con!=offline&role=client" Setting an alias vm, which list running vm (and show cpu) alias vm "list vm&status=running$cpu" ======= History ======= History is stored in ~/.local/share/cc-cli/history === TQL === Loading
bin/cc-cli +18 −24 Original line number Diff line number Diff line Loading @@ -23,36 +23,28 @@ settings = { "port": "1984", "timeout": "30", "hsize": "100", "config": "%s/cli"%BaseDirectory.save_config_path(cccli.canonical_name), "alias": "%s/alias"%BaseDirectory.save_config_path(cccli.canonical_name), "history": "%s/history"%BaseDirectory.save_data_path(cccli.canonical_name), } def load_config_file(config, filename, section): '''Update a dict with param from an ini file ''' if os.access(filename, os.R_OK): fparser = ConfigParser.RawConfigParser() fparser.read(filename) if fparser.has_section(section): config.update(fparser.items(section)) else: printer.warn("Unable to load file %s"%filename) def get_profile_path(profile): '''Force a profile path from a profile name''' return "%s/%s/%s.profile"%(BaseDirectory.xdg_config_home, cccli.canonical_name, profile) try: # load a printer printer = Printer(False) # parse config file if os.access(settings["config"], os.R_OK): load_config_file(settings, settings["config"], "cli") # parse profile file and load default profile try: propath = "%s/profile"%BaseDirectory.save_config_path(cccli.canonical_name) fparser = ConfigParser.RawConfigParser() fparser.read(propath) if fparser.has_section("cli"): settings.update(fparser.items("cli")) except Exception: fparser = None # parse config file profile # load "default profile" profile if "profile" in settings: load_config_file(settings, get_profile_path(settings["profile"]), "profile") if fparser is not None and fparser.has_section(settings["profile"]): settings.update(fparser.items(settings["profile"])) del settings["profile"] # parse env Loading @@ -67,9 +59,10 @@ try: if "CC_DEBUG" in os.environ: settings["debug"] = "True" # parse env profile # load env profile if "CC_PROFILE" in os.environ: load_config_file(settings, get_profile_path(os.environ["CC_PROFILE"]), "profile") if fparser is not None and fparser.has_section(os.environ["CC_PROFILE"]): settings.update(fparser.items(os.environ["CC_PROFILE"])) # Parse line argument oparser = optparse.OptionParser(usage="usage: %prog [options] [commands]", Loading Loading @@ -99,9 +92,10 @@ try: if o: settings[i] = o # parse argline file profile # load argline profile if "profile" in settings: load_config_file(settings, get_profile_path(settings["profile"]), "profile") if fparser is not None and fparser.has_section(settings["profile"]): settings.update(fparser.items(settings["profile"])) del settings["profile"] # debug stuff Loading
examples/clideleted 100644 → 0 +0 −4 Original line number Diff line number Diff line [cli] hsize = 1000 profile = lab
examples/lab.profiledeleted 100644 → 0 +0 −5 Original line number Diff line number Diff line [profile] login = sluttrin pass = toto42sh server = 192.168.0.162
examples/millet.profiledeleted 100644 → 0 +0 −6 Original line number Diff line number Diff line [profile] login = seblu pass = iloveseblu server = 192.168.0.41 debug = true