Sha256: d47a113bda7bd6d2d13ca5cdf042eafc505414d56672ae7685bd04b5a945316b

Contents?: true

Size: 1.6 KB

Versions: 13

Compression:

Stored size: 1.6 KB

Contents

require "thread"
require "vmc/cli/app/base"

module VMC::App
  class Files < Base
    desc "Print out an app's file contents"
    group :apps, :info
    input :app, :desc => "Application to inspect the files of",
          :argument => true, :from_given => by_name(:app)
    input :path, :desc => "Path of file to read", :argument => :optional,
          :default => "/"
    def file
      app = input[:app]
      path = input[:path]

      file =
        with_progress("Getting file contents") do
          app.file(*path.split("/"))
        end

      if quiet?
        print file
      else
        line

        file.split("\n").each do |l|
          line l
        end
      end
    rescue CFoundry::NotFound
      fail "Invalid path #{b(path)} for app #{b(app.name)}"
    rescue CFoundry::FileError => e
      fail e.description
    end

    desc "Examine an app's files"
    group :apps, :info
    input :app, :desc => "Application to inspect the files of",
          :argument => true, :from_given => by_name(:app)
    input :path, :desc => "Path of directory to list", :argument => :optional,
          :default => "/"
    def files
      app = input[:app]
      path = input[:path]

      if quiet?
        files =
          with_progress("Getting file listing") do
            app.files(*path.split("/"))
          end

        files.each do |file|
          line file.join("/")
        end
      else
        invoke :file, :app => app, :path => path
      end
    rescue CFoundry::NotFound
      fail "Invalid path #{b(path)} for app #{b(app.name)}"
    rescue CFoundry::FileError => e
      fail e.description
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cloulu-1.0.0 lib/vmc/cli/app/files.rb
cloulu-0.7.0 lib/vmc/cli/app/files.rb
cloulu-0.6.6 lib/vmc/cli/app/files.rb
cloulu-0.6.5 lib/vmc/cli/app/files.rb
cloulu-0.6.1 lib/vmc/cli/app/files.rb
cloulu-0.6.0 lib/vmc/cli/app/files.rb
cloulu-0.5.1 lib/vmc/cli/app/files.rb
cloulu-0.5.0 lib/vmc/cli/app/files.rb
cloulu-0.3.0 lib/vmc/cli/app/files.rb
cloulu-0.2.6 lib/vmc/cli/app/files.rb
cloulu-0.2.5 lib/vmc/cli/app/files.rb
cloulu-0.2.4 lib/vmc/cli/app/files.rb
cloulu-0.2.3 lib/vmc/cli/app/files.rb