Sha256: 91a6ffbaac17a0a42c075a6f0f7846b3a958363a7ae8b0006793b681670ed413

Contents?: true

Size: 1.62 KB

Versions: 5

Compression:

Stored size: 1.62 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-x64-mingw-ucrt lib/wx/wxruby/cmd/sampler.rb
wxruby3-0.9.0.pre.rc.2-x64-mingw-ucrt lib/wx/wxruby/cmd/sampler.rb
wxruby3-0.9.0.pre.rc.1-x64-mingw-ucrt lib/wx/wxruby/cmd/sampler.rb
wxruby3-0.9.0.pre.beta.14-x64-mingw-ucrt lib/wx/wxruby/cmd/sampler.rb
wxruby3-0.9.0.pre.beta.13-x64-mingw-ucrt lib/wx/wxruby/cmd/sampler.rb