Fix CLI. Add trailing CR to bundles
This commit is contained in:
parent
19a9b5b627
commit
589e3d9d6a
|
@ -10,7 +10,7 @@ module Pigeon
|
|||
.map { |multihash| s.find_message(multihash) }
|
||||
.map { |message| message.render }
|
||||
.join(BUNDLE_MESSAGE_SEPARATOR)
|
||||
File.write(file_path, content)
|
||||
File.write(file_path, content + "\n")
|
||||
end
|
||||
|
||||
def self.ingest(file_path)
|
||||
|
|
29
pigeon-cli
29
pigeon-cli
|
@ -10,7 +10,15 @@ def bail(msg)
|
|||
end
|
||||
|
||||
module Pigeon
|
||||
class Identity < Thor
|
||||
class ThorBase < Thor
|
||||
no_commands do
|
||||
def exit_on_failure?
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Identity < ThorBase
|
||||
class ConfigAlreadyExists < StandardError; end
|
||||
|
||||
desc "new", "Creates a new identiy in `.pigeon` directory if none exists"
|
||||
|
@ -34,7 +42,7 @@ module Pigeon
|
|||
end
|
||||
end
|
||||
|
||||
class Blob < Thor
|
||||
class Blob < ThorBase
|
||||
desc "set", "Copy arbitrary binary data into the database"
|
||||
|
||||
def set(data = "")
|
||||
|
@ -49,7 +57,7 @@ module Pigeon
|
|||
end
|
||||
end
|
||||
|
||||
class Peer < Thor
|
||||
class Peer < ThorBase
|
||||
desc "add", "Begin following a Pigeon peer"
|
||||
|
||||
def add(identity)
|
||||
|
@ -75,7 +83,7 @@ module Pigeon
|
|||
end
|
||||
end
|
||||
|
||||
class PigeonDraft < Thor
|
||||
class PigeonDraft < ThorBase
|
||||
desc "create", "Begin a new Pigeon message"
|
||||
|
||||
def create(kind)
|
||||
|
@ -113,7 +121,15 @@ module Pigeon
|
|||
end
|
||||
end
|
||||
|
||||
class CLI < Thor
|
||||
class PigeonBundle < ThorBase
|
||||
desc "create", "Create a pigeon bundle file"
|
||||
|
||||
def create(file_path = Pigeon::DEFAULT_BUNDLE_PATH)
|
||||
Pigeon::Bundle.create(file_path)
|
||||
end
|
||||
end
|
||||
|
||||
class CLI < ThorBase
|
||||
desc "status", "Show various information about the `.pigeon` directory"
|
||||
|
||||
def status
|
||||
|
@ -139,6 +155,9 @@ module Pigeon
|
|||
|
||||
desc "message SUBCOMMAND ...ARGS", "Manage messages"
|
||||
subcommand "draft", PigeonDraft
|
||||
|
||||
desc "bundle SUBCOMMAND ...ARGS", "Consume and create bundle files"
|
||||
subcommand "bundle", PigeonBundle
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
echo "Deleting old pigeon configs"
|
||||
rm -f db.pigeon
|
||||
rm -f pigeon.bundle
|
||||
echo "OK"
|
||||
|
||||
echo "Creating new config:"
|
||||
|
@ -76,5 +77,10 @@ echo "=== append hello:'world' to draft:"
|
|||
echo "=== Sign draft #2"
|
||||
./pigeon-cli draft sign
|
||||
|
||||
echo "=== Dump the bundle"
|
||||
./pigeon-cli bundle create
|
||||
cat pigeon.bundle
|
||||
echo "=== ^ Dump the bundle"
|
||||
|
||||
echo "=== getting status:"
|
||||
./pigeon-cli status
|
||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe Pigeon::Message do
|
|||
.map do |n| { "foo" => ["bar", 123, SecureRandom.uuid].sample } end
|
||||
.map do |d| create_message(d) end
|
||||
.map(&:render)
|
||||
.join("\n\n")
|
||||
.join("\n\n") + "\n"
|
||||
Pigeon::Bundle.create
|
||||
actual_bundle = File.read(Pigeon::DEFAULT_BUNDLE_PATH)
|
||||
expect(expected_bundle).to eq(actual_bundle)
|
||||
|
|
Loading…
Reference in New Issue