Sha256: c9e16729212ef6ada15cf37e975e88c71e39985b14ed26babe1cb2c4fbdd9fd9
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
#!/usr/bin/env ruby require "bundler/setup" require 'mkalias' VALID_OPTIONS = ['new', 'list', 'show', 'remove'] def usage puts "Usage: mkalias [option]" puts "option: new \t -> mkalias new [alias] [command]" puts "option: list \t -> mkalias list" puts "option: show \t -> mkalias show [alias]" puts "option: remove \t -> mkalias remove [alias]" puts "\n" puts "Attention: To make alias with args use #. Example:" puts " $ mkalias new [alias] \"echo #1 #2 #3\"" puts " - Then you can use: $ [alias] arg1 arg2 arg3" abort end def new_alias if ARGV.count < 3 usage end alias_name = ARGV[1] commands = ARGV[2..-1] result = Mkalias.new_alias(alias_name, commands) if result puts " - Created Alias: #{alias_name}" puts " - Run '$ source ~/.bashrc' to use your alias" else puts " ERROR: O Alias [#{alias_name}] já existe" end end def list_alias alias_names = Mkalias.list_alias puts "Registered Alias:" alias_names.each do |alias_name| puts " - #{alias_name}" end end def show_alias if ARGV.count < 2 usage end alias_name = ARGV[1] commands = Mkalias.show_alias(alias_name) if commands puts "#{alias_name}:" commands.each do |command| puts " #{command}" end else puts "Alias [#{alias_name}] not founded" end end def remove_alias if ARGV.count < 2 usage end alias_name = ARGV[1] removed = Mkalias.remove_alias(alias_name) if removed puts "Removed Alias: #{alias_name}" else puts "Alias [#{alias_name}] not founded" end end def main if ARGV.count == 0 || !VALID_OPTIONS.include?(ARGV[0]) usage end option = ARGV[0] if option == 'new' new_alias elsif option == 'list' list_alias elsif option == 'show' show_alias elsif option == 'remove' remove_alias else usage end end main
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mkalias-0.1.6 | bin/mkalias |