build-tool 0.5.7 → 0.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/.gitignore +1 -0
  2. data/.rvmrc +1 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +5 -0
  5. data/Gemfile.lock +56 -0
  6. data/History.txt +64 -0
  7. data/README.txt +0 -7
  8. data/Rakefile +8 -56
  9. data/bin/build-tool +4 -1
  10. data/build-tool.gemspec +62 -0
  11. data/db/migrations/20110703074000_add_command_logs.rb +17 -0
  12. data/db/migrations/20110703075000_add_module_logs.rb +20 -0
  13. data/db/migrations/20110815170000_add_features.rb +17 -0
  14. data/db/migrations/20120103204700_add_modules.rb +17 -0
  15. data/db/migrations/20120106181200_add_settings.rb +18 -0
  16. data/lib/build-tool.rb +3 -4
  17. data/lib/build-tool/application.rb +127 -37
  18. data/lib/build-tool/build-system/autoconf.rb +2 -8
  19. data/lib/build-tool/build-system/base.rb +12 -4
  20. data/lib/build-tool/build-system/cmake.rb +2 -0
  21. data/lib/build-tool/build-system/custom.rb +2 -0
  22. data/lib/build-tool/build-system/kdel10n.rb +2 -0
  23. data/lib/build-tool/build-system/make.rb +2 -0
  24. data/lib/build-tool/build-system/none.rb +2 -0
  25. data/lib/build-tool/build-system/qmake.rb +2 -0
  26. data/lib/build-tool/build-system/qt.rb +4 -0
  27. data/lib/build-tool/cfg/lexer.rex +40 -8
  28. data/lib/build-tool/cfg/lexer_base.rb +3 -1
  29. data/lib/build-tool/cfg/node.rb +17 -1
  30. data/lib/build-tool/cfg/parser.y +92 -10
  31. data/lib/build-tool/cfg/visitor.rb +202 -78
  32. data/lib/build-tool/command_actions.rb +26 -10
  33. data/lib/build-tool/commands.rb +289 -197
  34. data/lib/build-tool/commands/build.rb +13 -9
  35. data/lib/build-tool/commands/configuration.rb +25 -0
  36. data/lib/build-tool/commands/configuration/edit.rb +42 -0
  37. data/lib/build-tool/commands/configuration/list.rb +48 -0
  38. data/lib/build-tool/commands/configure.rb +9 -5
  39. data/lib/build-tool/commands/ctags.rb +8 -3
  40. data/lib/build-tool/commands/environments.rb +2 -4
  41. data/lib/build-tool/commands/environments/list.rb +13 -10
  42. data/lib/build-tool/commands/environments/set.rb +5 -1
  43. data/lib/build-tool/commands/features.rb +24 -0
  44. data/lib/build-tool/commands/features/disable.rb +70 -0
  45. data/lib/build-tool/commands/features/enable.rb +66 -0
  46. data/lib/build-tool/commands/features/list.rb +92 -0
  47. data/lib/build-tool/commands/fetch.rb +9 -3
  48. data/lib/build-tool/commands/files.rb +9 -5
  49. data/lib/build-tool/commands/gc.rb +48 -15
  50. data/lib/build-tool/commands/history.rb +21 -16
  51. data/lib/build-tool/commands/info.rb +16 -13
  52. data/lib/build-tool/commands/install.rb +8 -4
  53. data/lib/build-tool/commands/modules.rb +2 -4
  54. data/lib/build-tool/commands/modules/cleanup.rb +52 -0
  55. data/lib/build-tool/commands/modules/disable.rb +95 -0
  56. data/lib/build-tool/commands/modules/enable.rb +52 -0
  57. data/lib/build-tool/commands/modules/info.rb +44 -35
  58. data/lib/build-tool/commands/modules/list.rb +67 -15
  59. data/lib/build-tool/commands/modules/shell.rb +8 -2
  60. data/lib/build-tool/commands/rebase.rb +15 -7
  61. data/lib/build-tool/commands/recipes.rb +2 -4
  62. data/lib/build-tool/commands/recipes/add.rb +16 -2
  63. data/lib/build-tool/commands/recipes/edit.rb +72 -0
  64. data/lib/build-tool/commands/recipes/incoming.rb +11 -7
  65. data/lib/build-tool/commands/recipes/info.rb +12 -8
  66. data/lib/build-tool/commands/recipes/install.rb +37 -42
  67. data/lib/build-tool/commands/recipes/list.rb +6 -2
  68. data/lib/build-tool/configuration.rb +88 -3
  69. data/lib/build-tool/environment.rb +2 -0
  70. data/lib/build-tool/errors.rb +5 -0
  71. data/lib/build-tool/history.rb +3 -181
  72. data/lib/build-tool/model/command_log.rb +93 -0
  73. data/lib/build-tool/model/feature.rb +80 -0
  74. data/lib/build-tool/{module.rb → model/module.rb} +110 -29
  75. data/lib/build-tool/model/module_log.rb +64 -0
  76. data/lib/build-tool/model/setting.rb +84 -0
  77. data/lib/build-tool/recipe.rb +40 -18
  78. data/lib/build-tool/repository.rb +39 -33
  79. data/lib/build-tool/server.rb +27 -3
  80. data/lib/build-tool/singleton.rb +2 -0
  81. data/lib/build-tool/sshkey.rb +2 -0
  82. data/lib/build-tool/state_helper.rb +64 -0
  83. data/lib/build-tool/vcs/archive.rb +3 -1
  84. data/lib/build-tool/vcs/base.rb +13 -0
  85. data/lib/build-tool/vcs/git-svn.rb +36 -14
  86. data/lib/build-tool/vcs/git.rb +180 -44
  87. data/lib/build-tool/vcs/mercurial.rb +25 -13
  88. data/lib/build-tool/vcs/svn.rb +20 -15
  89. data/lib/build-tool/version.rb +30 -0
  90. data/lib/mj/error.rb +2 -0
  91. data/lib/mj/logging.rb +2 -0
  92. data/lib/mj/mixins/inherited_attributes.rb +73 -0
  93. data/lib/mj/tools/editor.rb +34 -0
  94. data/lib/mj/tools/ssh.rb +2 -0
  95. data/lib/mj/tools/subprocess.rb +2 -1
  96. data/lib/mj/vcs/git.rb +14 -2
  97. data/lib/mj/visitor.rb +22 -0
  98. data/tasks/db.rake +36 -0
  99. data/tasks/racc.rake +14 -0
  100. data/tasks/rdoc.rake +8 -0
  101. data/tasks/rexical.rake +14 -0
  102. data/tasks/test.rake +21 -0
  103. data/test/integration/history_test.rb +88 -0
  104. data/test/integration/parser_configuration.rb +36 -0
  105. data/test/integration/parser_environment_parser.rb +156 -0
  106. data/test/integration/parser_feature_test.rb +75 -0
  107. data/test/integration/parser_git-svn_test.rb +92 -0
  108. data/test/integration/parser_git_test.rb +97 -0
  109. data/test/integration/parser_mercurial_test.rb +77 -0
  110. data/test/integration/parser_module_test.rb +103 -0
  111. data/test/integration/parser_svn_test.rb +92 -0
  112. data/test/integration/parser_test.rb +73 -0
  113. data/test/test_helper.rb +61 -0
  114. data/test/unit/configuration_test.rb +36 -0
  115. data/test/unit/git_configuration_test.rb +163 -0
  116. data/test/unit/git_svn_configuration_test.rb +240 -0
  117. data/test/unit/mercurial_configuration_test.rb +64 -0
  118. data/test/unit/model/command_log_test.rb +103 -0
  119. data/test/unit/model/feature_test.rb +29 -0
  120. data/test/unit/model/module_log_test.rb +70 -0
  121. data/test/unit/model/module_test.rb +32 -0
  122. data/test/unit/repository_test.rb +110 -0
  123. data/test/unit/server_test.rb +66 -0
  124. data/test/unit/svn_configuration_test.rb +90 -0
  125. metadata +134 -93
  126. data/Manifest.txt +0 -80
  127. data/db/migrations/001_command_histories.rb +0 -20
  128. data/db/migrations/002_module_events.rb +0 -24
  129. data/db/migrations/003_command_histories_add_logfile.rb +0 -19
  130. data/lib/build-tool/GUI.rb +0 -360
  131. data/lib/build-tool/commands/help.rb +0 -22
  132. data/lib/build-tool/commands/lsfeatures.rb +0 -76
  133. data/lib/build-tool/feature.rb +0 -47
@@ -1,3 +1,6 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'mj/tools/subprocess'
1
4
  require 'build-tool/application'
2
5
  require 'build-tool/commands'
3
6
 
@@ -21,9 +24,10 @@ def log?
21
24
  end
22
25
 
23
26
  def initialize_options
24
- @options.banner = "Usage: #{Pathname.new($0).basename} #{self.fullname} MODULES..."
27
+ options.banner = "Usage: #{self.fullname} [OPTIONS]... MODULES..."
28
+ options.separator( "" )
29
+ options.separator( "Options" )
25
30
 
26
- @options.separator "Options:"
27
31
  @fast = false
28
32
  options.on( "--fast", "Fast install. No compile (if supported)" ) { |t|
29
33
  @fast = t
@@ -39,7 +43,7 @@ def applicable?
39
43
  def is_module_ready?( mod )
40
44
  isready = true
41
45
  if !mod.checkedout?
42
- logger.warn "#{mod.name}: module not checked out -> skipping."
46
+ warn( "#{mod.name}: module not checked out -> skipping." )
43
47
  end
44
48
  return isready
45
49
  end
@@ -49,7 +53,7 @@ def do_execute_module( mod )
49
53
  if mod.checkedout?
50
54
  install( mod, @fast )
51
55
  else
52
- logger.info "Not checked out. Skipping"
56
+ info( "Not checked out. Skipping" )
53
57
  end
54
58
  end
55
59
 
@@ -1,3 +1,5 @@
1
+ # -*- coding: UTF-8 -*-
2
+
1
3
  require 'build-tool/commands'
2
4
 
3
5
  module BuildTool; module Commands;
@@ -15,10 +17,6 @@ def applicable?
15
17
  BuildTool::Application.instance.has_recipe?
16
18
  end
17
19
 
18
- def do_execute
19
- raise NotImplementedError
20
- end
21
-
22
20
  end # class ModulesCLI
23
21
 
24
22
  end; end # module BuildTool::Commands::ModulesCLI
@@ -0,0 +1,52 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'build-tool/commands'
4
+
5
+ module BuildTool; module Commands; module Modules
6
+
7
+ #
8
+ # BuildCommand
9
+ #
10
+ class Cleanup < ModuleBasedCommand
11
+
12
+ name "cleanup"
13
+ description "Module related cleanup actions."
14
+ long_description [
15
+ "This commands makes it possible to do some module related cleanups. Take care to not",
16
+ "lose data." ]
17
+
18
+ def initialize_options
19
+ @all = true
20
+ options.banner = "Usage: #{self.fullname} [OPTIONS]... [MODULE|GROUP]..."
21
+ options.separator( "" )
22
+ options.separator( "Options" )
23
+
24
+ @remove_build_directory = false
25
+ options.on( "--rm-bld", "Remove the build directory." ) {
26
+ @remove_build_directory = true
27
+ }
28
+
29
+ @remove_source_directory = false
30
+ options.on( "--rm-src", "Remove the source directory." ) {
31
+ @remove_source_directory = true
32
+ }
33
+
34
+ options.on( "--rm-both", "Remove the source and build directory." ) {
35
+ @remove_source_directory = true
36
+ @remove_build_directory = true
37
+ }
38
+ super
39
+ end
40
+
41
+
42
+ def do_execute_module( mod )
43
+ remove_source_directory( mod, true ) if @remove_source_directory
44
+ remove_build_directory( mod, true ) if @remove_build_directory
45
+ end
46
+
47
+
48
+ end # class
49
+
50
+ end; end; end # module BuildTool::Commands::Modules
51
+
52
+
@@ -0,0 +1,95 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'build-tool/commands'
4
+
5
+ module BuildTool; module Commands; module Modules
6
+
7
+ #
8
+ # BuildCommand
9
+ #
10
+ class Disable < ModuleBasedCommand
11
+
12
+ name 'disable'
13
+ description 'Disable the given modules.'
14
+ long_description [ 'Sets the modules status.' ]
15
+
16
+ def initialize_options
17
+ options.banner = "Usage: #{self.fullname} [OPTIONS]... FEATURE..."
18
+ options.separator( "" )
19
+ options.separator( "Options" )
20
+
21
+ @default = false
22
+ options.on( "--default", "Set to use default state if possible." ) { |t|
23
+ @default = true
24
+ }
25
+
26
+ @remove_build_directory = false
27
+ options.on( "--rm-bld", "Remove the build directory." ) {
28
+ @remove_build_directory = true
29
+ }
30
+
31
+ @remove_source_directory = false
32
+ options.on( "--rm-src", "Remove the source directory." ) {
33
+ @remove_source_directory = true
34
+ }
35
+
36
+ options.on( "--rm-both", "Remove the source and build directory." ) {
37
+ @remove_source_directory = true
38
+ @remove_build_directory = true
39
+ }
40
+
41
+ super
42
+
43
+ # We want to allways match all modules here.
44
+ @all = true
45
+ end
46
+
47
+ def applicable?
48
+ BuildTool::Application.instance.has_recipe?
49
+ end
50
+
51
+ def do_execute( args )
52
+ super( args )
53
+ configuration.save()
54
+ return 0
55
+ end
56
+
57
+ def do_execute_module( mod )
58
+ if @default and mod.default_active? == false
59
+ info( '%s: using default (disabled).' % mod.name )
60
+ mod.active = nil
61
+ else
62
+ info( '%s: disabled explicitely.' % mod.name )
63
+ mod.active = false
64
+ end
65
+
66
+ if mod.source_directory.exist?
67
+ if @remove_source_directory
68
+ remove_source_directory( mod, true )
69
+ else
70
+ info( 'Source directory %s still exists.' % mod.source_directory )
71
+ verbose( 'module clean --rm-src to remove it' )
72
+ end
73
+ elsif @remove_source_directory
74
+ info( 'Source directory does not exist.' )
75
+ end
76
+
77
+
78
+ if mod.build_directory.exist?
79
+ if @remove_build_directory
80
+ remove_build_directory( mod, true )
81
+ else
82
+ info( 'Build directory %s still exists.' % mod.build_directory )
83
+ verbose( 'module clean --rm-bld to remove it' )
84
+ end
85
+ elsif @remove_build_directory
86
+ info( 'Build directory does not exist.' )
87
+ end
88
+ end
89
+
90
+ end # class Activate
91
+
92
+ end; end; end # module BuildTool::Commands::Modules
93
+
94
+
95
+
@@ -0,0 +1,52 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'build-tool/commands'
4
+
5
+ module BuildTool; module Commands; module Modules
6
+
7
+ #
8
+ # BuildCommand
9
+ #
10
+ class Enable < ModuleBasedCommand
11
+
12
+ name 'enable'
13
+ description 'Enable the given modules.'
14
+ long_description [ 'Sets the modules status.' ]
15
+
16
+ def initialize_options
17
+ options.banner = "Usage: #{self.fullname} [OPTIONS]... FEATURE..."
18
+ options.separator( "" )
19
+ options.separator( "Options" )
20
+
21
+ @default = false
22
+ options.on( "--default", "Set to use default state if possible." ) { |t|
23
+ @default = true
24
+ }
25
+
26
+ super
27
+
28
+ # We want to allways match all modules here.
29
+ @all = true
30
+ end
31
+
32
+ def applicable?
33
+ BuildTool::Application.instance.has_recipe?
34
+ end
35
+
36
+ def do_execute_module( mod )
37
+
38
+ if @default and mod.default_active? == true
39
+ info( '%-35s: using default (enabled).' % mod.name )
40
+ mod.active = nil
41
+ else
42
+ info( '%-35s: enabled explicitely.' % mod.name )
43
+ mod.active = true
44
+ end
45
+ end
46
+
47
+ end # class Activate
48
+
49
+ end; end; end # module BuildTool::Commands::Modules
50
+
51
+
52
+
@@ -1,3 +1,5 @@
1
+ # -*- coding: UTF-8 -*-
2
+
1
3
  require 'build-tool/commands'
2
4
 
3
5
  module BuildTool; module Commands; module Modules
@@ -12,88 +14,95 @@ class Info < ModuleBasedCommand
12
14
 
13
15
  def do_execute_module( mod )
14
16
  if mod.description
15
- say mod.description
16
- say ""
17
+ info( mod.description )
18
+ info( "" )
17
19
  else
18
- say "No description specified to the module"
19
- say ""
20
+ info( "No description specified to the module" )
21
+ info( "" )
22
+ end
23
+ if mod.long_description
24
+ info( mod.long_description )
25
+ info( "" )
20
26
  end
21
- say mod.long_description if mod.long_description
22
27
 
23
- say "Active: #{mod.active?}"
28
+ info( "Active: #{mod.active?}" )
29
+ info( "Status: #{mod.state}" )
24
30
 
25
31
  # if mod.repository
26
- # say "Repository: #{mod.repository.url}/#{mod.remote_path}"
32
+ # info( "Repository: #{mod.repository.url}/#{mod.remote_path}" )
27
33
  # if mod.repository.sshkey
28
- # say " SSH Key: '#{mod.repository.sshkey.name}' (#{mod.repository.sshkey.file})"
34
+ # info( " SSH Key: '#{mod.repository.sshkey.name}' (#{mod.repository.sshkey.file})" )
29
35
  # end
30
- # say "Apply Patches: #{mod.patches.join(", ")}"
36
+ # info( "Apply Patches: #{mod.patches.join(", ")}" )
31
37
  # else
32
- # say "Repository: not configured"
38
+ # info( "Repository: not configured" )
33
39
  # end
34
40
 
35
41
  if mod.build_prefix
36
- say "Local Checkout: #{mod.vcs.local_path} #{mod.checkedout? ? '(EXISTS)' : '(TODO)' }"
37
- say "Build Directory #{mod.build_directory} #{mod.configured? ? '(CONFIGURED)' : '(TODO)' }"
42
+ info( "Local Checkout: #{mod.vcs.local_path} #{mod.checkedout? ? '(EXISTS)' : '(TODO)' }" )
43
+ info( "Build Directory #{mod.build_directory} #{mod.configured? ? '(CONFIGURED)' : '(TODO)' }" )
38
44
  else
39
- say "Local Checkout: build-prefix not configured"
45
+ info( "Local Checkout: build-prefix not configured" )
40
46
  end
41
47
 
42
- say "Prefix: #{mod.install_prefix.to_s}"
48
+ info( "Prefix: #{mod.install_prefix.to_s}" )
43
49
  if mod.environment
44
- say "Environment:"
50
+ info( "Environment: %s (%s)" % [ mod.environment.name, mod.environment.active? ? 'A' : 'I' ] )
45
51
  mod.environment.vars.sort.each do |var|
46
- say " %-20s %s" % [ var + ":", mod.environment[var] ]
52
+ info( " %-20s %s" % [ var + ":", mod.environment[var] ] )
47
53
  end
48
54
  else
49
- say "Environment: Not configured"
55
+ info( "Environment: Not configured" )
50
56
  end
51
57
 
52
- say "VCS: #{mod.vcs_configuration ? mod.vcs_configuration.name : 'not configured' }"
58
+ info( "VCS: #{mod.vcs_configuration ? mod.vcs_configuration.name : 'not configured' }" )
53
59
  if mod.vcs_configuration
54
60
  case mod.vcs_configuration.name
55
61
  when 'svn'
56
- say " Repository: %s/%s" % [ mod.vcs_configuration.repository.url, mod.vcs_configuration.remote_path ]
62
+ info( " Repository: %s/%s" % [ mod.vcs_configuration.repository.url, mod.vcs_configuration.remote_path ] )
57
63
  when 'archive'
58
- say " URL: %s" % [ mod.vcs.archive_url ]
64
+ info( " URL: %s" % [ mod.vcs.archive_url ] )
59
65
  when 'git'
60
- mod.vcs_configuration.remote.each do |key, val|
66
+ mod.vcs_configuration.merged_remote.each do |key, val|
61
67
  if val.push_url
62
- say " Remote: %s -> %s (push to %s)" % [ key, val.url, val.push_url ]
68
+ info( " Remote: %s -> %s (push to %s)" % [ key, val.url, val.push_url ] )
63
69
  else
64
- say " Remote: %s -> %s" % [ key, val.url ]
70
+ info( " Remote: %s -> %s" % [ key, val.url ] )
65
71
  end
66
72
  end
67
- say " Track branch: #{mod.vcs_configuration.track_remote}/#{mod.vcs_configuration.track_branch}"
73
+ info( " Track branch: #{mod.vcs_configuration.track_remote}/#{mod.vcs_configuration.track_branch}" )
68
74
  when 'git-svn'
69
- say " Repository: %s/%s" % [ mod.vcs_configuration.repository.url, mod.vcs_configuration.remote_path ]
70
- mod.vcs_configuration.remote.each do |key, val|
71
- say " Remote: %s -> %s" % [ key, val.url ]
75
+ info( " Repository: %s/%s" % [ mod.vcs_configuration.repository.url, mod.vcs_configuration.remote_path ] )
76
+ mod.vcs_configuration.merged_remote.each do |key, val|
77
+ info( " Remote: %s -> %s" % [ key, val.url ] )
72
78
  end
73
- mod.vcs_configuration.externals.each do |key, val|
74
- say " External: #{key} -> #{val}"
79
+ mod.vcs_configuration.merged_externals.each do |key, val|
80
+ info( " External: #{key} -> #{val}" )
75
81
  end
76
82
  else
77
- logger.warn "Unknown vcs #{mod.vcs_configuration.name}"
83
+ warn( "Unknown vcs #{mod.vcs_configuration.name}" )
78
84
  end
79
85
  end # if mod.vcs_configuration
80
86
 
81
87
  bs = mod.build_system
82
88
  if bs
83
- say "Build System: #{bs.name}"
84
- say " Out Of Source Build #{bs.out_of_source}"
89
+ info( "Build System: #{bs.name}" )
90
+ info( " Out Of Source Build #{bs.out_of_source}" )
85
91
  bs.option_names.sort.each do |var|
86
- say " %-28s %s" % [ var + ":", bs[var] ]
92
+ info( " %-28s %s" % [ var + ":", bs[var] ] )
87
93
  end
88
94
  else
89
- say "Build System: Not configured"
95
+ info( "Build System: Not configured" )
90
96
  end
91
97
 
92
98
  return 0
93
99
  end
94
100
 
95
101
  def initialize_options
96
- @options.banner = "Usage: #{Pathname.new($0).basename} #{self.fullname} MODULES..."
102
+ options.banner = "Usage: #{self.fullname} [OPTIONS]... MODULES..."
103
+ options.separator( "" )
104
+ options.separator( "Options" )
105
+
97
106
  options.on( "--all", "Include inactive modules." ) {
98
107
  @all = true
99
108
  }
@@ -1,3 +1,5 @@
1
+ # -*- coding: UTF-8 -*-
2
+
1
3
  require 'build-tool/commands'
2
4
 
3
5
  module BuildTool; module Commands; module Modules
@@ -9,49 +11,99 @@ class List < Standard
9
11
 
10
12
  name "list"
11
13
  description "list modules"
12
- long_description [ "Shows a list of modules. Without a parameter all modules are show. With",
13
- "parameters list all modules matching them." ]
14
+ long_description [
15
+ "Shows a list of modules. Without a parameter all active modules are shown. When given",
16
+ "parameters list all modules matching them. The list is sorted alphabetically.",
17
+ "",
18
+ "The first two columns of the output are each one character wide:",
19
+ " First column: Is the module active?",
20
+ " 'A': Active",
21
+ " 'I': Inactive",
22
+ " Second column: State of the modules last build.",
23
+ " 'R': Running",
24
+ " 'C': Cancelled by user",
25
+ " 'S': Successfull",
26
+ " 'E': Had errors",
27
+ " Third column: The module name.",
28
+ " Fourth column: The modules short description." ]
14
29
  cmdalias "lsmods"
15
30
 
16
31
  def initialize_options
17
- @options.banner = "Usage: #{Pathname.new($0).basename} #{self.fullname} [MODULE|GROUP]..."
18
-
19
- @template = false
32
+ options.banner = "Usage: #{self.fullname} [OPTIONS]... [MODULE|GROUP]..."
33
+ options.separator( "" )
34
+ options.separator( "Options" )
20
35
 
21
- @options.separator "Options:"
36
+ @all = true
22
37
 
38
+ @active = true
39
+ @inactive = false
23
40
  options.on( "--all", "Include inactive modules." ) {
24
- @all = true
41
+ @active = true
42
+ @inactive = true
25
43
  }
26
44
 
45
+ options.on( "--disabled", "Only show inactive modules." ) {
46
+ @active = false
47
+ @inactive = true
48
+ }
49
+
50
+ @template = false
27
51
  options.on( "--template", "Include template modules." ) {
28
52
  @template = true
29
53
  }
30
54
 
55
+ @broken = false
56
+ options.on( "--broken", "Show only broken modules." ) {
57
+ @broken = true
58
+ }
59
+
60
+ @sort = true
61
+ options.on( "--no-sort", "Show modules in order of declaration." ) {
62
+ @sort = false
63
+ }
64
+
31
65
  super
32
66
  end
33
67
 
34
68
  def do_execute( args )
35
69
  # *TODO* listing local and remote recipes
36
70
  if args.length == 0
37
- configuration.modules.each do |mod|
38
- if @template or not mod.is_template?
39
- say "%-30s : %s" % [ mod.name, mod.description || "No description specified" ] if ( mod.active? || @all )
40
- end
41
- end
71
+ show_modules( configuration.modules )
42
72
  else
43
73
  args.each do |arg|
44
74
  mods = complete_modules( arg, @template )
45
75
  next if !mods
46
- mods.each do |mod|
47
- say "%-30s : %s" % [ mod.name, mod.description || "No description specified" ] if ( mod.active? || @all )
48
- end
76
+ show_modules( mods )
49
77
  end
50
78
  end
51
79
 
52
80
  return 0
53
81
  end
54
82
 
83
+ def show_modules( mods )
84
+ mods = mods.sort if @sort
85
+ mods.each do |mod|
86
+ show_module( mod )
87
+ end
88
+ end
89
+
90
+ def show_module( mod )
91
+ return if @broken and not mod.broken?
92
+ if mod.active?
93
+ return if not @active
94
+ else
95
+ return if not @inactive
96
+ end
97
+ return if mod.is_template? and not @template
98
+
99
+ if @broken
100
+ info( "%s%s %-35s : %-25s" % [ mod.active_char, mod.state_char, mod.name, mod.state ] )
101
+ else
102
+ info( "%s%s %-35s : %s" % [ mod.active_char, mod.state_char, mod.name, mod.description || "No description specified" ] )
103
+ end
104
+ end
105
+
106
+
55
107
  end # class
56
108
 
57
109
  end; end; end # module BuildTool::Commands::Modules