homesteading 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6792e28645cb8229d923ba0aaa1f9e04170a9af3
4
- data.tar.gz: c2cf6594cf27534151605d61405a564cc4200615
3
+ metadata.gz: d41012c5cf25936b063cac45455c91f8df72c39a
4
+ data.tar.gz: 881ca530b7404d9d34c6f3aa809a5e381a880676
5
5
  SHA512:
6
- metadata.gz: 552649b99c1c0e00d64d9b7b6a99f86f88b546b710100868b30bf33ae6f73d7212eae894d980a0c5ce4f2ea9c2ffe56db921cd1a9c1f6996ac1fcfcc3f2a7b4a
7
- data.tar.gz: 85c881e994998935b74379cb33d484194e7c6b95ae947ec675184f0919088add3cba56e74ee52046936463c0f8d78034ee7a68c3057f3a4d619b53036e9b9cdd
6
+ metadata.gz: 2f1d35f5ea21cdf887afa8e1659f53b017c4644c9846f12de069bcfd480b8138ee9c265b3917ae76baa82e8ec7be8b6394d86fe8600b019ed04bbf606f6179d1
7
+ data.tar.gz: 0e08056a1cf6d24c09893d1e71dc3e79f8693ed3e6cdbd9569fb94e4ba163983f05ceace2eeb9881aa822e0a63a6b7232030f245cda0dd4dd909b4506c8f572b
data/README.md CHANGED
@@ -37,9 +37,6 @@ To get started:
37
37
  ```bash
38
38
  homesteading new path/to/install/location
39
39
  cd path/to/install/location
40
- homesteading run rake hs:db:config
41
- homesteading run rake db:migrate
42
- homesteading run rake db:seed
43
40
  homesteading server
44
41
  ```
45
42
 
data/bin/homesteading CHANGED
@@ -3,28 +3,45 @@ require "optparse"
3
3
  require "fileutils"
4
4
  require "json"
5
5
  require "yaml"
6
- require "homesteading/commands/help"
6
+ require "homesteading/command"
7
7
 
8
+ dir = File.expand_path("../../lib/homesteading/commands", __FILE__)
9
+ # require all commands
10
+ Dir["#{dir}/*.rb"].each do |f|
11
+ require f
12
+ end
13
+
14
+ # require some command input
8
15
  if ARGV.empty?
9
- name_space = "Help"
10
- task = "default"
11
- Homesteading::Help.print("blank")
12
- else
13
- # special case for `hs -v` alias for `hs version`
14
- if ARGV.first.match(/^\s*-[vV]\s*$/)
15
- name_space = "Version"
16
- task = "default"
17
- else
18
- name_spaced_task = ARGV.shift.match(/^(\w+)(:*)(\w*)$/)
19
- name_space = name_spaced_task[1].capitalize
16
+ Homesteading::Help.new.print("blank")
17
+ exit 1
18
+ end
19
+
20
+ # special case for `hs -v` alias for `hs version`
21
+ if ARGV.first.match(/-[vV]/)
22
+ Homesteading::Version.new.default
23
+ exit 0
24
+ end
25
+
26
+ # normal flow
27
+ command_subcommand = ARGV.shift.match(/^(\w+)(:*)(\w*)$/)
28
+ command = command_subcommand[1]
29
+ klass = Homesteading::Command.create(command)
20
30
 
21
- if name_spaced_task[2] == ":"
22
- task = name_spaced_task[3]
23
- else
24
- task = "default"
25
- end
26
- end
31
+ unless klass
32
+ puts
33
+ puts "* Unknown command: #{command_subcommand}"
34
+ puts
35
+ exit 1
27
36
  end
28
37
 
29
- require "homesteading/commands/#{name_space.downcase}"
30
- Homesteading.const_get(name_space).send(task.to_sym)
38
+ subcommand = command_subcommand[2] == ":" ? command_subcommand[3] : "default"
39
+
40
+ if klass.class.public_method_defined?(subcommand.to_sym)
41
+ klass.send(subcommand.to_sym)
42
+ else
43
+ puts
44
+ puts "* Undefined subcommand: #{command_subcommand}"
45
+ puts
46
+ exit 1
47
+ end
@@ -0,0 +1,19 @@
1
+ module Homesteading
2
+ class Command
3
+ COMMANDS = {}
4
+
5
+ def self.register(name, *aliases)
6
+ COMMANDS[name] = self
7
+
8
+ aliases.each do |a|
9
+ COMMANDS[a] = self
10
+ end
11
+ end
12
+
13
+ def self.create(name)
14
+ if klass = COMMANDS[name]
15
+ klass.new
16
+ end
17
+ end
18
+ end
19
+ end