Permalink
Browse files

Cliche "First commit" message

Nothing really works at this stage except that "ppl list" does actually display
a list of contacts if you happen to have a directory containing valid vcard
files at "/home/henry/h2s/doc/contacts".

All I'm really aiming for with this commit is to set the stage for myself to
finally build the CLI address book for which I've been occasionally searching
for longer than I can remember.
  • Loading branch information...
hnrysmth committed Nov 10, 2012
0 parents commit e45917e06afd255271bad51ce216642e7277ce86
Showing with 539 additions and 0 deletions.
  1. +339 −0 COPYING.txt
  2. +5 −0 Gemfile
  3. +21 −0 Gemfile.lock
  4. +33 −0 README.md
  5. +15 −0 bin/ppl
  6. +4 −0 lib/ppl.rb
  7. +16 −0 lib/ppl/cli.rb
  8. +23 −0 lib/ppl/command.rb
  9. +16 −0 lib/ppl/command/base.rb
  10. +30 −0 lib/ppl/command/list.rb
  11. 0 lib/ppl/command/show.rb
  12. +15 −0 lib/ppl/ppl.rb
  13. +22 −0 ppl.gemspec

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,5 @@
gem "colored", "~> 1.2"
gem "vpim", "12.1.12", :git => "git://github.com/sam-github/vpim.git"
@@ -0,0 +1,21 @@
GIT
remote: git://github.com/defunkt/colored.git
revision: 829bde0f8832406be1cacc5c99c49d976e05ccfc
specs:
colored (1.2)
GIT
remote: git://github.com/sam-github/vpim.git
revision: 6753a367cda64e53eab745414cedc130d2f149c8
specs:
vpim (12.1.12)
GEM
specs:
PLATFORMS
ruby
DEPENDENCIES
colored (~> 1.2)!
vpim (= 12.1.12)!
@@ -0,0 +1,33 @@
_____ _____ __
| _ || _ || |
| __|| __|| |
|__| |__| |_____|
ppl aims to be address book software for command-line users. It's pronounced
like "people". You might be interested in ppl if:
* You like using the command-line
* You want ownership of your address book data back from the cloud
* You prefer to keep your data stored in an open format
The Plan
--------
ppl's command-line interface is based on those of Git and Heroku. For example:
$ ppl list
fred Fred Smith fred.smith@example.org
dave Dave Jones dave.jones@example.org
joe Joe Bloggs joe.bloggs@example.org
Or...
$ ppl show fred
Fred Smith
fred.simth@example.org
Birthday 1980-01-01
Cellphone 01189998819991197253
15 bin/ppl
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
require "pathname"
bin_file = Pathname.new(__FILE__).realpath
$:.unshift File.expand_path("../../lib", bin_file)
require "ppl/cli"
class String
alias_method :each, :each_line
end
Ppl::CLI.start *ARGV
@@ -0,0 +1,4 @@
module Ppl
end
@@ -0,0 +1,16 @@
require "ppl"
require "ppl/command"
class Ppl::CLI
def self.start(*args)
command = args.shift.strip
Ppl::Command.load
Ppl::Command.run(command, args)
end
end
@@ -0,0 +1,23 @@
module Ppl
module Command
def self.load
Dir[File.join(File.dirname(__FILE__), "command", "*.rb")].each do |file|
require file
end
end
def self.run(command, arguments=[])
options = {
:path => "/home/h2s/doc/contacts"
}
command = Ppl::Command::List.new(arguments, options)
command.send("index")
end
end
end
@@ -0,0 +1,16 @@
class Ppl::Command::Base
attr_reader :arguments
attr_reader :options
def initialize(arguments=[], options={})
@arguments = arguments
@options = options
end
end
@@ -0,0 +1,30 @@
require "vpim/vcard"
require "colored"
class Ppl::Command::List < Ppl::Command::Base
def index
pattern = @options[:path] + "/*.vcard"
contacts = Dir.glob pattern
contacts.each do |filename|
id = File.basename(filename).slice(0..-7)
vcard = IO.read filename
vcard = Vpim::Vcard.decode(vcard).first
puts(
sprintf("%-20s", id).red +
sprintf("%-20s", vcard.name.fullname).yellow +
sprintf("%-20s", vcard.email).blue
)
end
end
end
No changes.
@@ -0,0 +1,15 @@
module Ppl
class App
def run
puts ARGV
cmd = Ppl::Commands::List.new
end
end
end
@@ -0,0 +1,22 @@
Gem::Specification.new do |spec|
spec.name = "ppl"
spec.version = "0.0.2"
spec.date = "2012-11-10"
spec.summary = "CLI Address Book"
spec.description = "Command-line driven address book"
spec.license = "GPL-2"
spec.authors = ["Henry Smith"]
spec.email = "henry@henrysmith.org"
spec.executables = "ppl"
spec.files = `git ls-files`.split("\n")
spec.require_path = "lib"
spec.homepage = "https://github.com/h2s/ppl"
end

0 comments on commit e45917e

Please sign in to comment.