Sha256: cd8028d78049861bdd67ce4bb288e53a526bfbebabff701f5b77446aa9f7381f

Contents?: true

Size: 1.81 KB

Versions: 57

Compression:

Stored size: 1.81 KB

Contents

command 'change' do |c|
  c.syntax = 'brief change ATTRIBUTE [OPTIONS]'
  c.description = 'change attributes of brief documents'

  c.option '--from VALUE', String, 'Only apply when the attributes current value matches.'
  c.option '--to VALUE', String, 'Only apply when the attributes current value matches.'
  c.option '--root PATH', String, 'The root directory for the briefcase'
  c.option '--operator VALUE', String, 'What operator to use in matching the from value. (eq,neq,gt,gte,lt,lte). defaults: eq'
  c.option '--dry-run', nil, "Don't actually save"

  c.action do |args, options|
    options.default(root: Pathname(Brief.pwd), operator: "eq")
    attribute = args.shift
    paths     = args.map {|a| Dir[options.root.join(a)] }.flatten

    briefcase = Brief.case(true)
    documents = briefcase.documents_at(*paths)

    if options.from
      #attribute = attribute.to_sym.send(options.operator)
      attribute = attribute.to_sym
      documents = Brief::DocumentMapper::Query.new(documents).where({attribute => options.from}).all
    end

    if documents.length == 0
      puts "No documents match this selection"
    end

    if options.dry_run
      puts documents
    end

    documents
  end
end

command 'init' do |c|
  c.syntax = 'brief init NAME [OPTIONS]'
  c.description = 'Create a new brief project, aka a briefcase'

  c.option '--root', String, 'The root folder for the new project.'
  c.option '--app', String, 'Which existing app would you like to use?'

  c.action do |args, options|
    options.default :root => (args.first || Brief.pwd)

    root = Pathname(options.root)

    if root.join('brief.rb').exist?
      puts "A Brief project already exists in this folder"
    else
      require 'brief/briefcase/initializer'
      Brief::Briefcase.create_new_briefcase(root: root, app: options.app)
    end

    false
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
brief-1.17.11 lib/brief/cli/all.rb
brief-1.17.10 lib/brief/cli/all.rb
brief-1.17.9 lib/brief/cli/all.rb
brief-1.17.8 lib/brief/cli/all.rb
brief-1.17.7 lib/brief/cli/all.rb
brief-1.17.5 lib/brief/cli/all.rb
brief-1.17.4 lib/brief/cli/all.rb
brief-1.17.3 lib/brief/cli/all.rb
brief-1.17.2 lib/brief/cli/all.rb
brief-1.17.1 lib/brief/cli/all.rb
brief-1.17.0 lib/brief/cli/all.rb
brief-1.16.2 lib/brief/cli/all.rb
brief-1.16.1 lib/brief/cli/all.rb
brief-1.16.0 lib/brief/cli/all.rb
brief-1.15.5 lib/brief/cli/all.rb
brief-1.15.4 lib/brief/cli/all.rb
brief-1.15.3 lib/brief/cli/all.rb
brief-1.15.2 lib/brief/cli/all.rb
brief-1.15.1 lib/brief/cli/all.rb
brief-1.15.0 lib/brief/cli/all.rb