hfam 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8ffbaf7379c27828847ba8cedc0aa708ec97dc4
4
- data.tar.gz: c37cb86a42234f1332c31f78bcf035f7eefe23aa
3
+ metadata.gz: 8f717e2e3ed53363cc3edf32ede40df3e0a36ab0
4
+ data.tar.gz: df8e9ce5b49b07946d9b486d16accf4697c2a1cc
5
5
  SHA512:
6
- metadata.gz: 714122a472c5cdcdbfeeb60982e9ee2751b66f08439569b2f1e24240e1199658a6573a8ed2d7d15d42b3bc3dbac370011243ffcfd8e8fa519f5385eabd09debb
7
- data.tar.gz: 9d1bd61f378c7040dbdf4680d05514d423a473e70801c386d46d1c8c0fbee16bd8f4691d188c87b29de4c9907da057fdf151fb0caaa9d6c3e082fd3442742511
6
+ metadata.gz: b3b6d91a15895f9aaf232b7bb0611e85bc236e5b5aa3efc597cd30138ad922cb633283e838f9a559ecc2a8b8567d555879a1a5f5b7d698592d2df5bf47277fb8
7
+ data.tar.gz: 25768a7db70201cd1952a6872e4d4b2574b32c0b3ff9e0910a3430668bcbe5a2edc17fe47d8bb7cd72f4e3384fa39dcbf5b59a2fb7d38392ba8f20c055e83708
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  <b>H</b>idden <b>F</b>iles <b>A</b>re <b>M</b>anageable - Manage, source and reload you dotfiles in a specific directory
4
4
 
5
- 1. You create/clone your `dotfiles` directory defined in `$HOME/`.
6
- 2. You edit a `$HOME/dotfiles/.hfamconfig` with its intuitive DSL.
5
+ 1. You create/clone your `dotfiles`.
6
+ 2. You edit a `dotfiles/.hfamconfig` file with its intuitive DSL.
7
7
  3. You call `hfam`.
8
8
 
9
9
  The main advantage of this tool is that you can easily move your `dotfiles` from a machine to another one. Then, with only one command, you can configure your environment.
@@ -45,6 +45,45 @@ Example
45
45
  |- .hfamconfig
46
46
  ```
47
47
 
48
+ ####Options
49
+
50
+ Option `-h --help`
51
+
52
+ Display the usage:
53
+
54
+ ```shell
55
+ ?> hfam --help
56
+ HFAM - Hidden Files Are Manageable
57
+
58
+ Centralize your dotfiles in one directory and manage them using some basic operations (symlink, source, ...)
59
+ This tool attempts to locate a ~/dotfiles/.hfamconfig file. Then it executes a set of commands
60
+ listed in the config file.
61
+
62
+ For further information: https://github.com/mehdi-farsi/hfam
63
+
64
+ USAGE:
65
+
66
+ hfam [-h|--help] [-p|--path]
67
+
68
+ OPTIONS:
69
+
70
+ -h # help
71
+ -p # change the default dotfiles path
72
+ ```
73
+
74
+ Option `-p --path`
75
+
76
+ Change the default dotfiles path.
77
+
78
+ ```shell
79
+ ?> hfam --path /Users/zoidberg/Documents/dotfiles
80
+ Symlink: ln -s /Users/mehdi/Documents/dotfiles/testpath /Users/zoidberg/Documents/dotfiles/.testpath
81
+ ```
82
+
83
+ > The path set by --path option is the default symlink target path.
84
+ > use the DSL symlink option `:dest` to override this path.
85
+
86
+ ####Hfamconfig
48
87
 
49
88
  `hfam` works with a `.hfamconfig` file. This config file provide an intuitive DSL for managing your dotfiles.
50
89
 
@@ -57,9 +96,9 @@ For the following examples, let's say that the following environment variables a
57
96
 
58
97
  Now, let's have look to the `.hfamconfig` DSL.
59
98
 
60
- ####Symlink
99
+ #####Symlink
61
100
 
62
- The `symlink` command creates a symlink with the source file passed as argument. The symlink target is defined in `$HOME/.target`.
101
+ The `symlink` command creates a symlink with the source file passed as argument. The symlink target is created in `$HOME/.target`.
63
102
 
64
103
  Example:
65
104
 
@@ -78,7 +117,7 @@ Symlink: ln -s /Users/zoidberg/dotfiles/gitconfig /Users/zoidberg/.gitconfig
78
117
  /Users/zoidberg/.gitconfig -> /Users/zoidberg/dotfiles/gitconfig
79
118
  ```
80
119
 
81
- The `symlink` command accepts another argument to specify the destination's directory of the symlink. This arguments is named `dest`.
120
+ The `symlink` command accepts another argument to specify the destination's directory. This arguments is named `dest`.
82
121
 
83
122
  Example:
84
123
 
@@ -99,7 +138,7 @@ Symlink: ln -s /Users/mehdi/dotfiles/gitignore /Users/zoidberg/apps/my_app/.giti
99
138
  > lrwxr-xr-x 1 lol cat 27B Nov 11 16:35 .gitconfig -> /Users/zoidberg/dotfiles/gitconfig
100
139
  > ```
101
140
 
102
- ####Source
141
+ #####Source
103
142
 
104
143
  The `source` command creates a symlink using the file passed as argument and source the symlink target. The symlink target file is defined at `$HOME/.target`.
105
144
 
@@ -9,8 +9,8 @@ module HFAM
9
9
  end
10
10
 
11
11
  def run
12
- if @payload.metadata.include? :help
13
- puts @payload.metadata[:help]
12
+ if @payload.help_option?
13
+ puts @payload.help_message
14
14
  return
15
15
  end
16
16
 
@@ -6,12 +6,17 @@ module HFAM
6
6
  options = {}
7
7
 
8
8
  o = ::OptionParser.new do |opts|
9
+
9
10
  opts.banner = ::HFAM::HELP
10
11
 
11
-
12
- opts.on("-h") do |h|
12
+ opts.on("-h", "--help") do |h|
13
13
  options[:help] = ::HFAM::HELP
14
14
  end
15
+
16
+ opts.on("-p=PATH", "--path=PATH") do |p|
17
+ options[:path] = p
18
+ end
19
+
15
20
  end
16
21
  begin
17
22
  o.parse!
@@ -19,6 +24,9 @@ module HFAM
19
24
  $stderr.puts e
20
25
  $stderr.puts o.banner
21
26
  exit
27
+ rescue ::OptionParser::MissingArgument => e
28
+ $stderr.puts e
29
+ exit
22
30
  end
23
31
  options
24
32
  end
@@ -1,7 +1,6 @@
1
1
  module HFAM
2
- HOME = "#{ENV['HOME']}"
3
- DEFAULT_DOTFILE_PATH = "#{ENV['HOME']}/dotfiles"
4
- HFAMCONFIG_PATH = "#{DEFAULT_DOTFILE_PATH}/.hfamconfig"
2
+ HOME = "#{ENV['HOME']}"
3
+ DEFAULT_DOTFILES_PATH = "#{ENV['HOME']}/dotfiles"
5
4
 
6
5
  HELP = <<-SHELL
7
6
  HFAM - Hidden Files Are Manageable
@@ -14,11 +13,11 @@ For further information: https://github.com/mehdi-farsi/hfam
14
13
 
15
14
  USAGE:
16
15
 
17
- hfam [-h]
16
+ hfam [-h|--help] [-p|--path]
18
17
 
19
18
  OPTIONS:
20
19
 
21
20
  -h # help
22
-
21
+ -p # change the default dotfiles path
23
22
  SHELL
24
23
  end
@@ -6,16 +6,16 @@ module HFAM
6
6
  end
7
7
 
8
8
  def tokenize
9
- raw_commands = eval(::File.open(::HFAM::HFAMCONFIG_PATH).read)
9
+ raw_commands = eval(::File.open("#{dotfiles_path}/.hfamconfig").read)
10
10
  end
11
11
 
12
12
  def symlink(file, options = {})
13
- @payload.commands << [:symlink, "#{DEFAULT_DOTFILE_PATH}/#{file}", dest_path(file, options)]
13
+ @payload.commands << [:symlink, "#{dotfiles_path}/#{file}", dest_path(options)]
14
14
  end
15
15
 
16
16
  def source(file, options = {})
17
17
  symlink(file)
18
- @payload.commands << [:source, "#{DEFAULT_DOTFILE_PATH}/#{file}", dest_path(file, options)]
18
+ @payload.commands << [:source, "#{dotfiles_path}/#{file}", dest_path(options)]
19
19
  end
20
20
 
21
21
  def route
@@ -26,8 +26,15 @@ module HFAM
26
26
  @payload.commands << [:unknown, { command: method, args: args }]
27
27
  end
28
28
 
29
- def dest_path(file, options = {})
30
- options.include?(:dest) ? options[:dest] : ::HFAM::HOME
29
+ private
30
+ def dotfiles_path
31
+ # File::expand_path convert the builtin "~/" to the path defined in ENV["HOME"]
32
+ File.expand_path(@payload.metadata[:path] || DEFAULT_DOTFILES_PATH)
33
+ end
34
+
35
+ def dest_path(options = {})
36
+ # File::expand_path convert the builtin "~/" to the path defined in ENV["HOME"]
37
+ File.expand_path(options[:dest] || ::HFAM::HOME)
31
38
  end
32
39
  end
33
40
  end
@@ -8,6 +8,14 @@ module HFAM
8
8
  self[:commands] = Array.new { |value| [:unknown, value] }
9
9
  end
10
10
 
11
+ def help_option?
12
+ !!metadata[:help]
13
+ end
14
+
15
+ def help_message
16
+ metadata[:help]
17
+ end
18
+
11
19
  def metadata
12
20
  self[:metadata]
13
21
  end
@@ -1,3 +1,3 @@
1
1
  module HFAM
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hfam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mehdi_farsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-15 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.4.8
96
+ rubygems_version: 2.4.5.1
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Hidden Files Are Manageable