smc-get - Library and command-line for managing SMC level packages.
- Author
-
Luiji Maryo ([email protected])
- Contributor
-
Marvin Gülker ([email protected])
- Copyright
-
Copyright © 2010-2011 Entertaining Software, Inc.
- Copyright
-
Copyright © 2011 Marvin Gülker
- License
-
GNU General Public License (see COPYING)
smc-get install mypackage smc-get uninstall mypackage smc-get help
require 'smc_get' #Initialize the library SmcGet.setup( #From where to download packages "https://github.com/Luiji/Secret-Maryo-Chronicles-Contributed-Levels/raw/master/", #Where to install packages (your SMC installation) "/usr/local/share/smc" ) #Get a package pkg = SmcGet::Package.new("mypackage") #Install it! pkg.install #...or remove it. pkg.uninstall
smc-get is a library and command-line tool for installing, uninstalling, etc. level packages from the Secret Maryo Chronicles Contributed Levels Repository.
This program is a prototype for functionality that will eventually be merged with Secret Maryo Chronicles. It is subject to change and should not be used for anything other then testing.
smc-get’s main purpose is to be used as a command-line utility. It should be executed in the syntax:
smc-get COMMAND [PARAMETERS...]
Where COMMAND
is the command and PARAMATERS...
are the parameters for that command.
To get help on the various commands, use the help command.
smc-get help [COMMAND]
Ommit the COMMAND
if you want general usage information.
smc-get requires a configuration file when used as a commandline tool. By default it searches for smc-get.yml
in the config/ subdirectory of your smc-get installation, then for smc-get-conf.yml
in the user’s home directory and then for the file specified via the -c
commandline switch, if existant. Values set in later evaluated configuration files override those in prevously evaluated ones; see
smc-get help
for more explanation. If you want to use the CUI from your scripts, you can specify a config file via -c
, but make sure it contains all possible options, otherwise those in the global or user-level config files may affect your program. See below for an example.
Be careful when using sudo
, because it changes the environment variables. smc-get may not find your user-level configuration file when using sudo, because it derives the path from the USER
environment variable which may get set to root
when using sudo
.
In the configuration file you can set some general options, look into the file which is quite self-explanatory. A sample configuration may look like this:
data_directory: "/usr/local/share/smc" repo_url: "https://github.com/Luiji/Secret-Maryo-Chronicles-Contributed-Levels/raw/master/"
smc-get, although mainly targetted at being a command-line utility, may also be used as a library. This is useful when, for instance, creating a GUI front-end.
To initialize the library, indicate which repository you are using and where you want smc-get to install the packages to (which is usually your SMC installation path)
SmcGet.setup( "https://github.com/Luiji/Secret-Maryo-Chronicles-Contributed-Levels/raw/master/", "/usr/local/share/smc" )
For interacting with the SMC repository, smc-get exposes an object-oriented API centered around the SmcGet::Package class. After you initialized the library as explained above, you can query, install and uninstall packages.
pkg = SmcGet::Package.new("mypackage") pkg.install
If the function fails, it will raise various exceptions. When creating a GUI, you should catch these exceptions and present them as message boxes.
begin Package.new("mypackage").install rescue SmcGet::Errors::NoSuchPackageError alert 'No such package "mypackage"!' end
All errors smc-get raises are subclasses of SmcGet::Errors::SmcGetError. That means, if you rescue from this exception, you can handle all package-related errors at once:
begin Package.new("mypackage").install rescue SmcGet::Errors::SmcGetError => e alert e.message end
Furhtermore, these error messages should have a pretty informative message set, so unless you want to localize the error messages you can just reach them through (the messages, not the whole exceptions, of course).
The configuration file only contains settings for the commandline user interface, so you don’t need it here. If you want to use the CUI from your scripts, do
require "smc_get" require "smc_get/cui" cui = SmcGet::CUI.new(ARGV) cui.start
The configuration file from the config/ directory will automatically be loaded as well as the user-level configuration file; you may specify another configuration file by placing the appropriate option in ARGV:
ARGV.unshift("-c") ARGV.unshift("YOURCONFIGFILE.yml") cui = SmcGet::CUI.new(ARGV) cui.start
smc-get is licensed under the GNU General Public License. For more information, see COPYING.
This software was written by Entertaining Software, Inc. Visit us at www.entertainingsoftware.com.
This software is hosted at GitHub. The project page can be found at github.com/Luiji/smc-get.
This software was written for Secret Maryo Chronicles. Visit them at www.secretmaryo.org.