Sha256: 670aed7b5b38cc20844dde6345b3e1524f7bad0ae165f106422245141f29c8d3
Contents?: true
Size: 1.15 KB
Versions: 5
Compression:
Stored size: 1.15 KB
Contents
require 'highline' require 'cli-console' require 'daslabs' class ShellUI private extend CLI::Task public usage 'Usage: ls' desc 'List file information about current directory' def ls(params) Dir.foreach(Dir.pwd) do |file| puts file end end usage 'Usage: pwd' desc 'Display current directory' def pwd(params) puts "Current directory: #{Dir.pwd}" end usage 'Usage: cd <Directory>' desc 'Change current directory' def cd(params) Dir.chdir(params[0]) unless params.empty? end end io = HighLine.new shell = ShellUI.new console = CLI::Console.new(io) puts "Current directory: #{Dir.pwd}" daslabs = DasLabs.new daslabs.generate_android_xml("Welcome to DasLabs") console.addCommand('ls', shell.method(:ls), 'List files') console.addCommand('pwd', shell.method(:pwd), 'Current directory') console.addCommand('cd', shell.method(:cd), 'Change directory') console.addHelpCommand('help', 'Help') console.addExitCommand('exit', 'Exit from program') console.addAlias('quit', 'exit') console.start("%s> ",[Dir.method(:pwd)])
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
daslabs-0.12.0 | examples/shell.rb |
daslabs-0.11.0 | examples/shell.rb |
daslabs-0.10.0 | examples/shell.rb |
daslabs-0.9.0 | examples/shell.rb |
daslabs-0.8.0 | examples/shell.rb |