smc-get 0.2.0.beta1 → 0.3.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,65 +1,65 @@
1
- #Encoding: UTF-8
2
- ################################################################################
3
- # This file is part of smc-get.
4
- # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
- # Copyright (C) 2011 Marvin Gülker
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- ################################################################################
20
-
21
- module SmcGet
22
-
23
- module CUICommands
24
-
25
- class HelpCommand < Command
26
-
27
- def self.help
28
- <<EOF
29
- USAGE: #{File.basename($0)} help [SUBCOMMAND]
30
-
31
- Shows help for a special SUBCOMMAND or for #{File.basename($0)} in general.
32
- EOF
33
- end
34
-
35
- def self.summary
36
- "help\t\tGet help on a specific command."
37
- end
38
-
39
- def parse(args)
40
- CUI.debug("Parsing #{args.count} args for help.")
41
- raise(InvalidCommandline, "Too many arguments.") if args.count > 1
42
- @command = args.shift #nil if not given
43
- end
44
-
45
- def execute(config)
46
- CUI.debug("Executing help.")
47
- if @command
48
- sym = :"#{@command.capitalize}Command"
49
- if CUICommands.const_defined?(sym)
50
- puts CUICommands.const_get(sym).help
51
- else
52
- puts "#{@command} is not a valid command."
53
- return 2
54
- end
55
- else
56
- puts CUI::GENERAL_HELP
57
- end
58
- end
59
-
60
- end
61
-
62
- end
63
-
64
- end
1
+ #Encoding: UTF-8
2
+ ################################################################################
3
+ # This file is part of smc-get.
4
+ # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
+ # Copyright (C) 2011 Marvin Gülker
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ ################################################################################
20
+
21
+ module SmcGet
22
+
23
+ module CUICommands
24
+
25
+ class HelpCommand < Command
26
+
27
+ def self.help
28
+ <<EOF
29
+ USAGE: #{File.basename($0)} help [SUBCOMMAND]
30
+
31
+ Shows help for a special SUBCOMMAND or for #{File.basename($0)} in general.
32
+ EOF
33
+ end
34
+
35
+ def self.summary
36
+ "help\t\tGet help on a specific command."
37
+ end
38
+
39
+ def parse(args)
40
+ CUI.debug("Parsing #{args.count} args for help.")
41
+ raise(InvalidCommandline, "Too many arguments.") if args.count > 1
42
+ @command = args.shift #nil if not given
43
+ end
44
+
45
+ def execute(config)
46
+ CUI.debug("Executing help.")
47
+ if @command
48
+ sym = :"#{@command.capitalize}Command"
49
+ if CUICommands.const_defined?(sym)
50
+ puts CUICommands.const_get(sym).help
51
+ else
52
+ puts "#{@command} is not a valid command."
53
+ return 2
54
+ end
55
+ else
56
+ puts CUI::GENERAL_HELP
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end
65
65
  # vim:set ts=8 sts=2 sw=2 et: #
@@ -1,101 +1,101 @@
1
- #Encoding: UTF-8
2
- ################################################################################
3
- # This file is part of smc-get.
4
- # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
- # Copyright (C) 2011 Marvin Gülker
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- ################################################################################
20
-
21
- module SmcGet
22
-
23
- module CUICommands
24
-
25
- class InstallCommand < Command
26
-
27
- def self.help
28
- <<HELP
29
- USAGE: #{File.basename($0)} install [-r] PACKAGES
30
-
31
- Installs one or more packages.
32
-
33
- OPTIONS:
34
- -r\t--reinstall\tForces a reinstallation of the package.
35
- HELP
36
- end
37
-
38
- def self.summary
39
- "install\tInstall one or more packages."
40
- end
41
-
42
- def parse(args)
43
- CUI.debug("Parsing #{args.count} args for install.")
44
- raise(InvalidCommandline, "No package given.") if args.empty?
45
- @reinstall = false
46
- @pkg_names = []
47
-
48
- until args.empty?
49
- arg = args.shift
50
- case arg
51
- when "--reinstall", "-r" then @reinstall = true
52
- else
53
- @pkg_names << arg
54
- $stderr.puts("Unknown argument #{arg}. Treating it as a package.") if arg.start_with?("-")
55
- end
56
- end
57
- end
58
-
59
- def execute(config)
60
- CUI.debug("Executing install.")
61
-
62
- @pkg_names.each do |pkg_name|
63
- if @cui.local_repository.contains?(pkg_name)
64
- if @reinstall
65
- puts "Reinstalling #{pkg_name}."
66
- else
67
- puts "#{pkg_name} is already installed. Maybe you want --reinstall?."
68
- next
69
- end
70
- end
71
- puts "Installing #{pkg_name}."
72
- spec_file = pkg_name + ".yml"
73
- pkg_file = pkg_name + ".smcpak"
74
-
75
- begin
76
- path = download_package(pkg_name)
77
- pkg = Package.from_file(path)
78
- puts pkg.spec.install_message if pkg.spec.install_message
79
- print "Decompressing... "
80
- @cui.local_repository.install(pkg)
81
- puts "Done."
82
- rescue => e
83
- $stderr.puts(e.message)
84
- $stderr.puts("Ignoring the problem, continueing with the next package, if any.")
85
- if CUI.debug_mode?
86
- $stderr.puts("Class: #{e.class}")
87
- $stderr.puts("Message: #{e.message}")
88
- $stderr.puts("Backtrace:")
89
- $stderr.puts(e.backtrace.join("\n\t"))
90
- end
91
- end
92
- end #each
93
- end #execute
94
-
95
- end
96
-
97
- end
98
-
99
- end
100
-
101
- # vim:set ts=8 sts=2 sw=2 et: #
1
+ #Encoding: UTF-8
2
+ ################################################################################
3
+ # This file is part of smc-get.
4
+ # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
+ # Copyright (C) 2011 Marvin Gülker
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ ################################################################################
20
+
21
+ module SmcGet
22
+
23
+ module CUICommands
24
+
25
+ class InstallCommand < Command
26
+
27
+ def self.help
28
+ <<HELP
29
+ USAGE: #{File.basename($0)} install [-l][-r] PACKAGES
30
+
31
+ Installs one or more packages.
32
+
33
+ OPTIONS:
34
+ -l\t--local\t\tInstalls a package from the local filesystem.
35
+ \t\t\tPACKAGES are treated as file paths.
36
+ -r\t--reinstall\tForces a reinstallation of the package.
37
+ HELP
38
+ end
39
+
40
+ def self.summary
41
+ "install\tInstall one or more packages."
42
+ end
43
+
44
+ def parse(args)
45
+ CUI.debug("Parsing #{args.count} args for install.")
46
+ raise(InvalidCommandline, "No package given.") if args.empty?
47
+ @reinstall = false
48
+ @local = false
49
+ @pkg_names = []
50
+
51
+ until args.empty?
52
+ arg = args.shift
53
+ case arg
54
+ when "--local", "-l" then @local = true
55
+ when "--reinstall", "-r" then @reinstall = true
56
+ else
57
+ @pkg_names << arg
58
+ $stderr.puts("Unknown argument #{arg}. Treating it as a package.") if arg.start_with?("-")
59
+ end
60
+ end
61
+ end
62
+
63
+ def execute(config)
64
+ CUI.debug("Executing install.")
65
+
66
+ @pkg_names.each do |pkg_name|
67
+ begin
68
+ if @local
69
+ pkg = Package.from_file(pkg_name)
70
+ if @cui.local_repository.contains?(pkg) and !@reinstall
71
+ puts "#{pkg.spec.name} is already installed. Maybe you want --reinstall?"
72
+ next
73
+ end
74
+ puts "Resolving dependencies for #{pkg.spec.name}..."
75
+ pkg.spec.dependencies.each{|dep| install_package_with_deps(dep, @reinstall, [], true)}
76
+ puts "Installing #{pkg.spec.name} from local file..."
77
+ puts pkg.spec.install_message if pkg.spec.install_message
78
+ @cui.local_repository.install(pkg)
79
+ else
80
+ install_package_with_deps(pkg_name, @reinstall)
81
+ end
82
+ rescue => e
83
+ $stderr.puts(e.message)
84
+ $stderr.puts("Ignoring the problem, continueing with the next package, if any.")
85
+ if CUI.debug_mode?
86
+ $stderr.puts("Class: #{e.class}")
87
+ $stderr.puts("Message: #{e.message}")
88
+ $stderr.puts("Backtrace:")
89
+ $stderr.puts(e.backtrace.join("\n\t"))
90
+ end #if debug mode
91
+ end #begin
92
+ end #each
93
+ end #execute
94
+
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+
101
+ # vim:set ts=8 sts=2 sw=2 et: #
@@ -1,101 +1,101 @@
1
- #Encoding: UTF-8
2
- ################################################################################
3
- # This file is part of smc-get.
4
- # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
- # Copyright (C) 2011 Marvin Gülker
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- ################################################################################
20
-
21
- module SmcGet
22
-
23
- module CUICommands
24
-
25
- class ListCommand < Command
26
-
27
- def self.help
28
- <<EOF
29
- USAGE: #{File.basename($0)} list [PACKAGE]
30
-
31
- If PACKAGE is given, lists all files installed by PACKAGE. Otherwise,
32
- all installed packages are listed accompanied by their last-update
33
- date in the format DD-MM-YYYY HH:MM, where the time is given on a
34
- 24-hour clock.
35
- EOF
36
- end
37
-
38
- def self.summary
39
- "list\t\tLists all installed packages or files installed by a package. "
40
- end
41
-
42
- def parse(args)
43
- CUI.debug("Parsing #{args.count} args for list.")
44
- raise(InvalidCommandline, "Too many arguments.") if args.count > 1
45
- @pkg_name = args.shift #nil if not specified
46
- end
47
-
48
- def execute(config)
49
- CUI.debug("Executing list")
50
- if @pkg_name
51
- spec = PackageSpecification.from_file(@cui.local_repository.fetch_spec("#{@pkg_name}.yml", SmcGet.temp_dir))
52
- puts "Files installed for #{spec.name}:"
53
- puts "====================#{'=' * spec.name.length}="
54
- puts
55
-
56
- puts "Levels:"
57
- if spec.levels.empty?
58
- puts "\t(none)"
59
- else
60
- spec.levels.sort.each{|lvl| puts "\t- #{lvl}"}
61
- end
62
- puts
63
-
64
- puts "Music:"
65
- if spec.music.empty?
66
- puts "\t(none)"
67
- else
68
- spec.music.sort.each{|m| puts "\t- #{m}"}
69
- end
70
- puts
71
-
72
- puts "Graphics:"
73
- if spec.graphics.empty?
74
- puts "\t(none)"
75
- else
76
- spec.graphics.sort.each{|g| puts "\t- #{g}"}
77
- end
78
- puts
79
-
80
- puts "Worlds:"
81
- if spec.worlds.empty?
82
- puts "\t(none)"
83
- else
84
- spec.worlds.sort.each{|w| puts "\t- #{w}"}
85
- end
86
- else
87
- printf("%-38s | %-38s\n", "Package", "Last updated")
88
- print("-" * 39, "+", "-" * 40, "\n")
89
- @cui.local_repository.package_specs.sort_by{|spec| spec.name}.each do |spec|
90
- #The "last update" of a package in the *local* repository is it’s installation time.
91
- printf("%-38s | %-38s\n", spec.name, spec.last_update.localtime.strftime("%d-%m-%Y %H:%M"))
92
- end
93
- end
94
- end
95
-
96
- end
97
-
98
- end
99
-
100
- end
101
- # vim:set ts=8 sts=2 sw=2 et: #
1
+ #Encoding: UTF-8
2
+ ################################################################################
3
+ # This file is part of smc-get.
4
+ # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
+ # Copyright (C) 2011 Marvin Gülker
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ ################################################################################
20
+
21
+ module SmcGet
22
+
23
+ module CUICommands
24
+
25
+ class ListCommand < Command
26
+
27
+ def self.help
28
+ <<EOF
29
+ USAGE: #{File.basename($0)} list [PACKAGE]
30
+
31
+ If PACKAGE is given, lists all files installed by PACKAGE. Otherwise,
32
+ all installed packages are listed accompanied by their last-update
33
+ date in the format DD-MM-YYYY HH:MM, where the time is given on a
34
+ 24-hour clock.
35
+ EOF
36
+ end
37
+
38
+ def self.summary
39
+ "list\t\tLists all installed packages or files installed by a package. "
40
+ end
41
+
42
+ def parse(args)
43
+ CUI.debug("Parsing #{args.count} args for list.")
44
+ raise(InvalidCommandline, "Too many arguments.") if args.count > 1
45
+ @pkg_name = args.shift #nil if not specified
46
+ end
47
+
48
+ def execute(config)
49
+ CUI.debug("Executing list")
50
+ if @pkg_name
51
+ spec = PackageSpecification.from_file(@cui.local_repository.fetch_spec("#{@pkg_name}.yml", SmcGet.temp_dir))
52
+ puts "Files installed for #{spec.name}:"
53
+ puts "====================#{'=' * spec.name.length}="
54
+ puts
55
+
56
+ puts "Levels:"
57
+ if spec.levels.empty?
58
+ puts "\t(none)"
59
+ else
60
+ spec.levels.sort.each{|lvl| puts "\t- #{lvl}"}
61
+ end
62
+ puts
63
+
64
+ puts "Music:"
65
+ if spec.music.empty?
66
+ puts "\t(none)"
67
+ else
68
+ spec.music.sort.each{|m| puts "\t- #{m}"}
69
+ end
70
+ puts
71
+
72
+ puts "Graphics:"
73
+ if spec.graphics.empty?
74
+ puts "\t(none)"
75
+ else
76
+ spec.graphics.sort.each{|g| puts "\t- #{g}"}
77
+ end
78
+ puts
79
+
80
+ puts "Worlds:"
81
+ if spec.worlds.empty?
82
+ puts "\t(none)"
83
+ else
84
+ spec.worlds.sort.each{|w| puts "\t- #{w}"}
85
+ end
86
+ else
87
+ printf("%-38s | %-38s\n", "Package", "Last updated")
88
+ print("-" * 39, "+", "-" * 40, "\n")
89
+ @cui.local_repository.package_specs.sort_by{|spec| spec.name}.each do |spec|
90
+ #The "last update" of a package in the *local* repository is it’s installation time.
91
+ printf("%-38s | %-38s\n", spec.name, spec.last_update.localtime.strftime("%d-%m-%Y %H:%M"))
92
+ end
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+
100
+ end
101
+ # vim:set ts=8 sts=2 sw=2 et: #