Linker script update
This commit is contained in:
parent
588d7001cc
commit
adac8f4754
|
@ -1,12 +1,15 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require 'pp'
|
#/ Usage: dotlinker <command>
|
||||||
require 'docopt'
|
#/
|
||||||
|
#/ list List files to link
|
||||||
|
#/ update Update dotfiles repo
|
||||||
|
#/ symlink Symlink all files
|
||||||
|
#/ unsymlink Unsymlink all files
|
||||||
|
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
VERSION = '0.0.1'
|
|
||||||
|
|
||||||
module ShellHelpers
|
module ShellHelpers
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
|
@ -26,6 +29,10 @@ module ShellHelpers
|
||||||
"\033[0;#{COLOR_CODES[color] + 30}m#{str}\033[0m"
|
"\033[0;#{COLOR_CODES[color] + 30}m#{str}\033[0m"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def say_help
|
||||||
|
exec "grep ^#/<'#{__FILE__}'|cut -c4-"
|
||||||
|
end
|
||||||
|
|
||||||
def say(message, color = :default)
|
def say(message, color = :default)
|
||||||
$stdout.print(colorify_string(message, color))
|
$stdout.print(colorify_string(message, color))
|
||||||
$stdout.flush
|
$stdout.flush
|
||||||
|
@ -154,6 +161,7 @@ class Linker
|
||||||
include FileHelpers
|
include FileHelpers
|
||||||
include ShellHelpers
|
include ShellHelpers
|
||||||
|
|
||||||
|
VERSION = '0.1.0'.freeze
|
||||||
LINKDIR_FILENAME = '.linkdir'.freeze
|
LINKDIR_FILENAME = '.linkdir'.freeze
|
||||||
|
|
||||||
def git_dir
|
def git_dir
|
||||||
|
@ -209,35 +217,24 @@ class Linker
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
doc = <<DOCOPT
|
COMMANDS = ['list', 'update', 'symlink', 'unsymlink'].freeze
|
||||||
dotfiles linker
|
|
||||||
|
|
||||||
Usage:
|
command = ARGV.pop
|
||||||
linker list
|
if command.nil? || !COMMANDS.include?(command)
|
||||||
linker update
|
ShellHelpers.say_help
|
||||||
linker symlink
|
else
|
||||||
linker unsymlink
|
|
||||||
linker -h | --help
|
|
||||||
linker --version
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-h, --help Show this message.
|
|
||||||
--version Print the version.
|
|
||||||
DOCOPT
|
|
||||||
|
|
||||||
begin
|
|
||||||
linker = Linker.new
|
linker = Linker.new
|
||||||
docopt = Docopt.docopt(doc, version: VERSION)
|
|
||||||
|
|
||||||
if docopt['symlink']
|
case command
|
||||||
linker.symlink_all
|
when 'list'
|
||||||
elsif docopt['unsymlink']
|
|
||||||
linker.unsymlink_all
|
|
||||||
elsif docopt['update']
|
|
||||||
linker.update
|
|
||||||
elsif docopt['list']
|
|
||||||
linker.list_all
|
linker.list_all
|
||||||
|
when 'update'
|
||||||
|
linker.update
|
||||||
|
when 'symlink'
|
||||||
|
linker.symlink_all
|
||||||
|
when 'unsymlink'
|
||||||
|
linker.unsymlink_all
|
||||||
|
else
|
||||||
|
ShellHelpers.say_help
|
||||||
end
|
end
|
||||||
rescue Docopt::Exit => e
|
|
||||||
puts e.message
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue