dotfiles-cli 0.1.1
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 +7 -0
- data/bin/dotfiles +4 -0
- data/lib/dotfiles/core/install.rb +65 -0
- data/lib/dotfiles/core/response.rb +62 -0
- data/lib/dotfiles/core.rb +181 -0
- data/lib/dotfiles/parse/options.rb +82 -0
- data/lib/dotfiles/parse/parser.rb +43 -0
- data/lib/dotfiles/utils/fs.rb +44 -0
- data/lib/dotfiles/utils/get.rb +90 -0
- data/lib/dotfiles/utils/permissive.rb +24 -0
- data/lib/dotfiles.rb +42 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b2e74c2b7d5ee9cc31003b337cdfe2c0f8eb0371
|
4
|
+
data.tar.gz: de12b9d8fb8dca04ea79fb6595fafffc1ddfc9cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 59be2c4d557d25493b94fbad85eff07c7925aaec1e8e6d1961f5327bb507e720846ccdf6a92415e3ab349c8348944502ceeb29a60dfd5086e005542cf8652265
|
7
|
+
data.tar.gz: 3bb90e3348c147cf5920eff126f09774ddd1ddf0acd2aaccd587e35f3226a73cfda3c78bd7a826ecae021c739ce43822260e6e8c910089b63469128131822fe5
|
data/bin/dotfiles
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Copyright (c) 2018 exstnce
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# File: install.rb
|
16
|
+
# Project: dotfiles-cli
|
17
|
+
# Author: exstnce (exstnce@protonmail.ch)
|
18
|
+
# Created on Sunday, 8th July 2018 9:55:50 pm
|
19
|
+
|
20
|
+
require 'dotfiles/utils/fs'
|
21
|
+
require 'dotfiles/utils/permissive'
|
22
|
+
|
23
|
+
module Install
|
24
|
+
include Sudo
|
25
|
+
include FileSystem
|
26
|
+
# /etc
|
27
|
+
@@etc = '/etc/'
|
28
|
+
# ~/
|
29
|
+
@@root = File.expand_path('~')+'/'
|
30
|
+
# ~/Scripts
|
31
|
+
@@scripts = @@root+'Scripts/'
|
32
|
+
# ~/Pictures
|
33
|
+
@@pictures = @@root+'Pictures/'
|
34
|
+
# ~/.config
|
35
|
+
@@config = @@root+'.config/'
|
36
|
+
|
37
|
+
def self.etc(path)
|
38
|
+
contents = FileSystem.contents(path)
|
39
|
+
Sudo.copy(contents, @@etc)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.config(path)
|
43
|
+
contents = FileSystem.contents(path)
|
44
|
+
Sudo.copy(contents, @@config)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.tools(path)
|
48
|
+
contents = FileSystem.contents(path)
|
49
|
+
Sudo.copy(contents, @@root)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.scripts(name, path)
|
53
|
+
contents = FileSystem.contents(path)
|
54
|
+
scripts = FileSystem.mkdir(@@scripts+name)
|
55
|
+
|
56
|
+
Sudo.copy(contents, scripts)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.wallpapers(name, path)
|
60
|
+
contents = FileSystem.contents(path)
|
61
|
+
pictures = FileSystem.mkdir(@@pictures+name)
|
62
|
+
|
63
|
+
Sudo.copy(contents, pictures)
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Copyright (c) 2018 exstnce
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# File: response.rb
|
16
|
+
# Project: dotfiles-cli
|
17
|
+
# Author: exstnce (exstnce@protonmail.ch)
|
18
|
+
# Created on Sunday, 8th July 2018 4:37:56 pm
|
19
|
+
|
20
|
+
require 'colorize'
|
21
|
+
|
22
|
+
module Response
|
23
|
+
def self.help
|
24
|
+
puts 'Usage:'
|
25
|
+
puts ' dotfiles install [LINK]'
|
26
|
+
puts ' dotfiles use [NAME]'
|
27
|
+
puts ' dotfiles save [NAME]'
|
28
|
+
puts ' dotfiles delete [NAME]'
|
29
|
+
puts 'Further help:'
|
30
|
+
puts ' dotfiles help [COMMAND]'
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.install
|
34
|
+
puts "#{"Usage".cyan}: dotfiles install \"https://github.com/username/dotfiles\""
|
35
|
+
puts
|
36
|
+
puts ' Installs a remote repository.'
|
37
|
+
puts ' Contents can be found in ~/.dotfiles'
|
38
|
+
puts
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.use
|
42
|
+
puts "#{"Usage".cyan}: dotfiles use \"name\""
|
43
|
+
puts
|
44
|
+
puts ' Switches the configuration files.'
|
45
|
+
puts
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.save
|
49
|
+
puts "#{"Usage".cyan}: dotfiles save"
|
50
|
+
puts
|
51
|
+
puts ' Backups your system\'s dotfiles.'
|
52
|
+
puts
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.delete
|
56
|
+
puts "#{"Usage".cyan}: dotfiles delete \"name\""
|
57
|
+
puts
|
58
|
+
puts ' Completely deletes the dotfile\'s directory'
|
59
|
+
puts ' by a given name.'
|
60
|
+
puts
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
# Copyright (c) 2018 exstnce
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# File: core.rb
|
16
|
+
# Project: dotfiles-cli
|
17
|
+
# Author: exstnce (exstnce@protonmail.ch)
|
18
|
+
# Created on Sunday, 8th July 2018 5:15:53 pm
|
19
|
+
|
20
|
+
require 'git'
|
21
|
+
require 'colorize'
|
22
|
+
|
23
|
+
require_relative 'utils/fs'
|
24
|
+
require_relative 'utils/get'
|
25
|
+
require_relative 'utils/permissive'
|
26
|
+
require_relative 'core/install'
|
27
|
+
require_relative 'core/response'
|
28
|
+
|
29
|
+
module Core
|
30
|
+
include Get
|
31
|
+
include Sudo
|
32
|
+
include FileSystem
|
33
|
+
include Install
|
34
|
+
include Response
|
35
|
+
|
36
|
+
@config_is_empty = Dir.entries(@@config).size <= 2
|
37
|
+
|
38
|
+
def self.help(command=nil)
|
39
|
+
if command == nil
|
40
|
+
Response.help
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
|
44
|
+
case command.downcase
|
45
|
+
when 'install'
|
46
|
+
Response.install
|
47
|
+
when 'use'
|
48
|
+
Response.use
|
49
|
+
when 'save'
|
50
|
+
Response.save
|
51
|
+
when 'delete'
|
52
|
+
Response.delete
|
53
|
+
else
|
54
|
+
Response.help
|
55
|
+
end
|
56
|
+
exit
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.install(link)
|
60
|
+
name = Get.name
|
61
|
+
path = Get.path(name)
|
62
|
+
|
63
|
+
begin
|
64
|
+
Git.clone(link, path)
|
65
|
+
rescue Exception => e
|
66
|
+
puts "#{"Error".red}: Could not clone the repository"
|
67
|
+
puts
|
68
|
+
puts e.message
|
69
|
+
exit
|
70
|
+
end
|
71
|
+
|
72
|
+
puts "#{name.cyan} #{"successfully installed".green}"
|
73
|
+
puts "Path: #{path}"
|
74
|
+
|
75
|
+
print 'Do you want to use the installed dotfiles? (Y/n) '
|
76
|
+
use = Get.answer
|
77
|
+
|
78
|
+
if use
|
79
|
+
use(name)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.use(name)
|
84
|
+
path = Get.exists(name)
|
85
|
+
|
86
|
+
print 'Backup current dotfiles? (Y/n) '
|
87
|
+
save = Get.answer
|
88
|
+
|
89
|
+
if save
|
90
|
+
save()
|
91
|
+
end
|
92
|
+
|
93
|
+
scan(name, path)
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.save
|
97
|
+
name = Get.name
|
98
|
+
path = Get.path(name)
|
99
|
+
|
100
|
+
init(path)
|
101
|
+
|
102
|
+
config(path)
|
103
|
+
tools(path)
|
104
|
+
|
105
|
+
print 'Do you also want to backup your /etc directory? (Y/n) '
|
106
|
+
backup = Get.answer
|
107
|
+
|
108
|
+
if backup
|
109
|
+
etc(path)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.delete(name)
|
114
|
+
path = Get.exists(name)
|
115
|
+
|
116
|
+
FileUtils.rm_rf(path)
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def self.init(path)
|
122
|
+
Dir.mkdir(path)
|
123
|
+
Dir.mkdir(path+'config/')
|
124
|
+
Dir.mkdir(path+'tools/')
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.config(path)
|
128
|
+
contents = FileSystem.dot(@@config)
|
129
|
+
path+='config/'
|
130
|
+
|
131
|
+
Sudo.copy(contents, path)
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.tools(path)
|
135
|
+
# Returns an array of ~/.* files
|
136
|
+
contents = FileSystem.rglob(@@root)
|
137
|
+
path+='tools/'
|
138
|
+
|
139
|
+
Sudo.copy(contents, path)
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.etc(path)
|
143
|
+
contents = FileSystem.contents(@@etc)
|
144
|
+
path+='etc/'
|
145
|
+
|
146
|
+
Dir.mkdir(path)
|
147
|
+
Sudo.copy(contents, path)
|
148
|
+
end
|
149
|
+
|
150
|
+
def self.scan(name, path)
|
151
|
+
# ~/.dotfiles/name/etc
|
152
|
+
etc = path+'etc/'
|
153
|
+
if File.exists?(etc)
|
154
|
+
Install.config(etc)
|
155
|
+
end
|
156
|
+
|
157
|
+
# ~/.dotfiles/name/config
|
158
|
+
config = path+'config/'
|
159
|
+
if File.exists?(config)
|
160
|
+
Install.config(config)
|
161
|
+
end
|
162
|
+
|
163
|
+
# ~/.dotfiles/name/tools
|
164
|
+
tools = path+'tools/'
|
165
|
+
if File.exists?(tools)
|
166
|
+
Install.tools(tools)
|
167
|
+
end
|
168
|
+
|
169
|
+
# ~/.dotfiles/name/scripts
|
170
|
+
scripts = path+'scripts/'
|
171
|
+
if File.exists?(scripts)
|
172
|
+
Install.scripts(name, scripts)
|
173
|
+
end
|
174
|
+
|
175
|
+
# ~/.dotfiles/name/wallpapers
|
176
|
+
wallpapers = path+'wallpapers/'
|
177
|
+
if File.exists?(wallpapers)
|
178
|
+
Install.wallpapers(name, wallpapers)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Copyright (c) 2018 exstnce
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# File: options.rb
|
16
|
+
# Project: dotfiles-cli
|
17
|
+
# Author: exstnce (exstnce@protonmail.ch)
|
18
|
+
# Created on Friday, 6th July 2018 5:26:25 pm
|
19
|
+
|
20
|
+
require 'optparse'
|
21
|
+
|
22
|
+
require 'dotfiles/core'
|
23
|
+
require_relative 'parser'
|
24
|
+
|
25
|
+
module Options
|
26
|
+
include Core
|
27
|
+
include CommandParser
|
28
|
+
@version = 'dotfiles 0.1.0'
|
29
|
+
|
30
|
+
def self.parse
|
31
|
+
OptionParser.new do |opts|
|
32
|
+
|
33
|
+
opts.on('-h', '--help', 'Show help message') do
|
34
|
+
Core.help
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on('-v', '--version', 'Show dotfiles version') do
|
38
|
+
puts @version
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
end.parse!
|
42
|
+
|
43
|
+
CommandParser.new do |opts|
|
44
|
+
opts.on_empty do
|
45
|
+
Core.help
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on('help') do |command|
|
49
|
+
Core.help(command)
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on('install') do |link|
|
53
|
+
if link.nil?
|
54
|
+
Core.help('install')
|
55
|
+
end
|
56
|
+
|
57
|
+
Core.install(link)
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on('use') do |name|
|
61
|
+
if name.nil?
|
62
|
+
Core.help('use')
|
63
|
+
end
|
64
|
+
|
65
|
+
Core.use(name)
|
66
|
+
end
|
67
|
+
|
68
|
+
opts.on('save') do
|
69
|
+
Core.save
|
70
|
+
abort("No results were returned for that query")
|
71
|
+
end
|
72
|
+
|
73
|
+
opts.on('delete') do |name|
|
74
|
+
if name.nil?
|
75
|
+
Core.help('delete')
|
76
|
+
end
|
77
|
+
|
78
|
+
Core.delete(name)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright (c) 2018 exstnce
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# File: parser.rb
|
16
|
+
# Project: dotfiles-cli
|
17
|
+
# Author: exstnce (exstnce@protonmail.ch)
|
18
|
+
# Created on Monday, 9th July 2018 3:32:36 pm
|
19
|
+
|
20
|
+
module Option
|
21
|
+
def self.on_empty
|
22
|
+
if ARGV.empty?
|
23
|
+
yield
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.on(arg)
|
28
|
+
if arg == ARGV[0].downcase
|
29
|
+
if ARGV.length >= 2 && !ARGV[1].strip.empty?
|
30
|
+
yield ARGV[1].strip
|
31
|
+
else
|
32
|
+
yield
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module CommandParser
|
39
|
+
include Option
|
40
|
+
def self.new
|
41
|
+
yield Option
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright (c) 2018 exstnce
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# File: fs.rb
|
16
|
+
# Project: dotfiles-cli
|
17
|
+
# Author: exstnce (exstnce@protonmail.ch)
|
18
|
+
# Created on Monday, 9th July 2018 9:47:06 pm
|
19
|
+
|
20
|
+
module FileSystem
|
21
|
+
|
22
|
+
def self.dot(path)
|
23
|
+
path+'.'
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.contents(path)
|
27
|
+
path+'*'
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.mkdir(path)
|
31
|
+
Dir.mkdir(path) unless File.exists?(path)
|
32
|
+
path
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.rglob(root)
|
36
|
+
files = Dir.glob(root+'.*')
|
37
|
+
|
38
|
+
files.delete(root+'.dotfiles/')
|
39
|
+
files.delete(root+'.')
|
40
|
+
files.delete(root+'..')
|
41
|
+
|
42
|
+
files
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# Copyright (c) 2018 exstnce
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# File: get.rb
|
16
|
+
# Project: dotfiles-cli
|
17
|
+
# Author: exstnce (exstnce@protonmail.ch)
|
18
|
+
# Created on Sunday, 8th July 2018 5:53:22 pm
|
19
|
+
|
20
|
+
module Get
|
21
|
+
# ~/
|
22
|
+
@@root = File.expand_path('~')+'/'
|
23
|
+
# ~/.dotfiles
|
24
|
+
@@dotfiles = @@root+'.dotfiles/'
|
25
|
+
|
26
|
+
def self.name
|
27
|
+
print 'Save as: '
|
28
|
+
@name = STDIN.gets.chomp.delete(' ')
|
29
|
+
check
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.path(name)
|
33
|
+
@@dotfiles+name+'/'
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.exists(name)
|
37
|
+
path = path(name)
|
38
|
+
unless File.exists?(path)
|
39
|
+
puts "#{"Error".red}: #{name} does not exist"
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
path
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.answer
|
46
|
+
answer = STDIN.gets.chomp
|
47
|
+
|
48
|
+
if answer.strip.downcase == 'y' || answer.strip == ''
|
49
|
+
return true
|
50
|
+
end
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def self.check
|
57
|
+
if @name.empty?
|
58
|
+
name
|
59
|
+
end
|
60
|
+
|
61
|
+
@path = @@dotfiles+@name+'/'
|
62
|
+
|
63
|
+
if File.exists?(@path)
|
64
|
+
puts "#{"Warn".yellow}: #{@name} already exists"
|
65
|
+
puts
|
66
|
+
puts ' (1) Delete the directory'
|
67
|
+
puts
|
68
|
+
puts ' (2) Select a different name'
|
69
|
+
puts
|
70
|
+
puts ' (3) Exit'
|
71
|
+
puts
|
72
|
+
print 'Please, choose the desired option (default=2): '
|
73
|
+
option = STDIN.gets.chomp.strip
|
74
|
+
|
75
|
+
case option
|
76
|
+
when option.length > 1
|
77
|
+
name
|
78
|
+
when '1'
|
79
|
+
FileUtils.rm_rf(@path)
|
80
|
+
when '2'
|
81
|
+
name
|
82
|
+
when '3'
|
83
|
+
exit
|
84
|
+
else
|
85
|
+
name
|
86
|
+
end
|
87
|
+
end
|
88
|
+
@name
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright (c) 2018 exstnce
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# File: permissive.rb
|
16
|
+
# Project: dotfiles-cli
|
17
|
+
# Author: exstnce (exstnce@protonmail.ch)
|
18
|
+
# Created on Sunday, 8th July 2018 7:11:23 pm
|
19
|
+
|
20
|
+
module Sudo
|
21
|
+
def self.copy(from, to)
|
22
|
+
system "sudo cp -R #{from} #{to}"
|
23
|
+
end
|
24
|
+
end
|
data/lib/dotfiles.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Copyright (c) 2018 exstnce
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
# File: dotfiles.rb
|
16
|
+
# Project: dotfiles-cli
|
17
|
+
# Author: exstnce (exstnce@protonmail.ch)
|
18
|
+
# Created on Friday, 6th July 2018 5:23:29 pm
|
19
|
+
|
20
|
+
require 'dotfiles/parse/options'
|
21
|
+
|
22
|
+
class App
|
23
|
+
include Options
|
24
|
+
# Creates ~/.config if not already exists
|
25
|
+
Dir.mkdir(@@config) unless File.exists?(@@config)
|
26
|
+
# Creates ~/Pictures if not already exists
|
27
|
+
Dir.mkdir(@@pictures) unless File.exists?(@@pictures)
|
28
|
+
|
29
|
+
# Creates ~/.dotfiles directory
|
30
|
+
# App's root directory
|
31
|
+
Dir.mkdir(@@dotfiles) &&
|
32
|
+
FileUtils.chmod("u=xwr,go=xwr", @@dotfiles) unless File.exists?(@@dotfiles)
|
33
|
+
|
34
|
+
# Creates ~/Scripts directory
|
35
|
+
# Stores the custom scripts
|
36
|
+
Dir.mkdir(@@scripts) &&
|
37
|
+
FileUtils.chmod("u=xwr,go=xwr", @@scripts) unless File.exists?(@@scripts)
|
38
|
+
|
39
|
+
def self.run
|
40
|
+
Options.parse
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dotfiles-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- exstnce
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Tool to easy install, use and manage Linux configuration files.
|
14
|
+
email: exstnce@protonmail.ch
|
15
|
+
executables:
|
16
|
+
- dotfiles
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/dotfiles
|
21
|
+
- lib/dotfiles.rb
|
22
|
+
- lib/dotfiles/core.rb
|
23
|
+
- lib/dotfiles/core/install.rb
|
24
|
+
- lib/dotfiles/core/response.rb
|
25
|
+
- lib/dotfiles/parse/options.rb
|
26
|
+
- lib/dotfiles/parse/parser.rb
|
27
|
+
- lib/dotfiles/utils/fs.rb
|
28
|
+
- lib/dotfiles/utils/get.rb
|
29
|
+
- lib/dotfiles/utils/permissive.rb
|
30
|
+
homepage: https://github.com/exstnce/dotfiles-cli
|
31
|
+
licenses:
|
32
|
+
- Apache-2.0
|
33
|
+
metadata: {}
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 2.5.2.3
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Dotfiles-cli is a tool to easy install, use and manage Linux configuration
|
54
|
+
files.
|
55
|
+
test_files: []
|