Sha256: 7bfb1be748291a1c943deff4343079e2f5eef3d3a69f8871a783a85302b86523

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

# wxruby sampler command handler
# Copyright (c) M.J.N. Corino, The Netherlands
#--------------------------------------------------------------------

require 'fileutils'

module WxRuby
  module Commands
    class Sampler
      OPTIONS = {
        save_path: nil
      }

      def self.description
        "    sampler [help]|[copy DEST]\tRun wxRuby3 Sampler application (or copy samples)."
      end

      def self.run(argv)
        if argv == :describe
          description
        else
          if argv.empty?
            exec(RUBY, File.join(WxRuby::ROOT, 'samples', 'sampler.rb'))
          else
            arg = argv.shift
            if arg == 'help'
              puts 'Usage: wxruby [global options] sampler [help]|[copy DEST]'
              puts
              puts '    Starts the sampler application if called without arguments.'
              puts '    Otherwise shows this help for argument "help" or copies the included wxRuby'
              puts '    sample folders under the directory indicated by DEST for argument "copy DEST".'
              puts '    The directory indicated by DEST *must* already exist.'
              puts
            elsif arg == 'copy'
              unless File.directory?(dest = argv.shift)
                STDERR.puts "ERROR: Invalid destination folder #{dest}"
                exit(1)
              end
              Dir[File.join(WxRuby::ROOT, 'samples', '*')].each do |fp|
                FileUtils.cp_r(fp, dest, verbose: true)
              end
            end
          end
        end
      end
    end

    self.register('sampler', Sampler)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wxruby3-0.9.0.pre.rc.3 lib/wx/wxruby/cmd/sampler.rb
wxruby3-0.9.0.pre.rc.2 lib/wx/wxruby/cmd/sampler.rb
wxruby3-0.9.0.pre.rc.1 lib/wx/wxruby/cmd/sampler.rb
wxruby3-0.9.0.pre.beta.14 lib/wx/wxruby/cmd/sampler.rb
wxruby3-0.9.0.pre.beta.13 lib/wx/wxruby/cmd/sampler.rb