Class: EnfCli::Shell::CLI
Overview
Shell CLI class
Instance Method Summary collapse
- #cat(file) ⇒ Object
- #cd(dir = "~") ⇒ Object
- #clear ⇒ Object
- #host ⇒ Object
- #ls(dir = nil) ⇒ Object
- #pwd ⇒ Object
Methods inherited from EnfThor
Instance Method Details
#cat(file) ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/enfcli.rb', line 332 def cat(file) try_with_rescue do # expand path file = EnfCli::(file) ## return if keyfile not found raise EnfCli::ERROR, "#{file} not found!" unless File.exists?(file) say File.readlines(file).join end end |
#cd(dir = "~") ⇒ Object
352 353 354 355 356 357 358 |
# File 'lib/enfcli.rb', line 352 def cd(dir = "~") try_with_rescue do dir = EnfCli::( dir ) raise EnfCli::ERROR, "No such directory #{dir}" unless Dir.exist?(dir) Dir.chdir(dir) end end |
#clear ⇒ Object
368 369 370 371 372 373 |
# File 'lib/enfcli.rb', line 368 def clear try_with_rescue do clear_code = %x{clear} print clear_code or system("cls") end end |
#host ⇒ Object
361 362 363 364 365 |
# File 'lib/enfcli.rb', line 361 def host try_with_rescue do say EnfCli::CTX.instance.host, :bold end end |
#ls(dir = nil) ⇒ Object
320 321 322 323 324 325 326 327 328 329 |
# File 'lib/enfcli.rb', line 320 def ls(dir = nil) try_with_rescue do dir = "." unless dir dir = EnfCli::( dir ) Dir.entries( dir ).each{ |f| puts f unless f.start_with?('.') } end end |
#pwd ⇒ Object
345 346 347 348 349 |
# File 'lib/enfcli.rb', line 345 def pwd try_with_rescue do say Dir.pwd end end |