diary 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,10 +10,27 @@ module Diary
10
10
  # Create files
11
11
  create_file "templates/index.html.erb", "<%= content %>"
12
12
  create_file "config.yml", "sync:\n user: \n server: \n path: \n"
13
+
14
+ unless File.exists?(".git")
15
+ if options.git
16
+ Diary.message :git, "Initial commit", :magenta
17
+ init_git!
18
+ else
19
+ Diary.message :skip, "git init", :red
20
+ end
21
+ else
22
+ Diary.message :git, "Already a git repository", :yellow
23
+ end
13
24
  end
14
25
 
15
26
  private
16
27
 
28
+ def init_git!
29
+ `git init`
30
+ `git add .`
31
+ `git commit -m "Initial commit"`
32
+ end
33
+
17
34
  def create_dir(path)
18
35
  unless File.exists?(path)
19
36
  FileUtils.mkdir_p(path)
@@ -6,14 +6,19 @@ module Diary
6
6
  def parse(args)
7
7
  options = OpenStruct.new
8
8
  options.force = false
9
+ options.git = true
9
10
 
10
11
  opts = OptionParser.new do |opts|
11
12
  opts.banner = "Usage: diary ACTION [-vf]"
12
13
 
13
14
  opts.separator "\nSpecific options:"
14
15
 
15
- opts.on("-f", "--[no-]force", "Force all items to compile") do |f|
16
- options.force = f
16
+ opts.on("-f", "--[no-]force", "Force all items to compile") do |force|
17
+ options.force = force
18
+ end
19
+
20
+ opts.on("-g", "--[no-]git", "Git init the repository.") do |git|
21
+ options.git = git
17
22
  end
18
23
 
19
24
  opts.separator "\nCommon options:"
@@ -1,3 +1,3 @@
1
1
  module Diary
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Robin Clart
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-04 00:00:00 +01:00
17
+ date: 2011-03-05 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency