Add `message find` and `message find-all` (local user only - find-all for peers 🔜)
This commit is contained in:
parent
f296a71890
commit
4b87a58b0e
|
@ -33,8 +33,10 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`.
|
|||
- [X] pigeon bundle create
|
||||
- [X] Use JSON.stringify() for string keys (instead of `inspect`)
|
||||
- [X] Move literals into `Pigeon` module as constants, again.
|
||||
- [ ] pigeon message find
|
||||
- [ ] pigeon message find-all (then refactor ::Bundle.create to use it!)
|
||||
- [X] pigeon message find
|
||||
- [X] pigeon message find-all for local feed.
|
||||
- [ ] pigeon message find-all for peer feed. I will need to add index for `author => message_count`
|
||||
- [ ] refactor `Bundle.create` to use `message find-all`.
|
||||
- [ ] pigeon bundle consume
|
||||
- [ ] add parsers and validators for all CLI inputs
|
||||
- [ ] Ensure all disks writes perform verification!
|
||||
|
|
|
@ -37,6 +37,20 @@ module Pigeon
|
|||
end
|
||||
end
|
||||
|
||||
def find_all
|
||||
# TODO: Ability to pass an author ID to `find-all`
|
||||
author = Pigeon::KeyPair.current
|
||||
store = Pigeon::Storage.current
|
||||
all = []
|
||||
depth = -1
|
||||
last = ""
|
||||
until (last == nil) || (depth > 999999)
|
||||
last = store.get_message_by_depth(author, depth += 1)
|
||||
all.push(last) if last
|
||||
end
|
||||
return all
|
||||
end
|
||||
|
||||
def set_config(key, value)
|
||||
store.transaction do
|
||||
store[CONF_NS][key] = value
|
||||
|
|
27
pigeon-cli
27
pigeon-cli
|
@ -129,6 +129,30 @@ module Pigeon
|
|||
end
|
||||
end
|
||||
|
||||
class PigeonMessage < ThorBase
|
||||
desc "find", "Find a pigeon message in the local DB"
|
||||
|
||||
def find(multihash)
|
||||
puts Pigeon::Storage.current.find_message(multihash).render
|
||||
end
|
||||
|
||||
desc "find-all", "Find a pigeon message in the local DB"
|
||||
|
||||
def find_all()
|
||||
# TODO: Ability to find-all messages by author ID
|
||||
puts Pigeon::Storage.current.find_all.join(Pigeon::CR) + Pigeon::CR
|
||||
end
|
||||
|
||||
desc "last", "Grab your last message. INTERNAL USE ONLY"
|
||||
|
||||
def last
|
||||
me = Pigeon::KeyPair.current
|
||||
store = Pigeon::Storage.current
|
||||
multihash = store.get_message_by_depth(me, store.message_count - 1)
|
||||
puts multihash
|
||||
end
|
||||
end
|
||||
|
||||
class CLI < ThorBase
|
||||
desc "status", "Show various information about the `.pigeon` directory"
|
||||
|
||||
|
@ -156,6 +180,9 @@ module Pigeon
|
|||
desc "identity SUBCOMMAND ...ARGS", "Manage `.pigeon` identity"
|
||||
subcommand "identity", Identity
|
||||
|
||||
desc "message SUBCOMMAND ...ARGS", "Manage blob storage"
|
||||
subcommand "message", PigeonMessage
|
||||
|
||||
desc "peer SUBCOMMAND ...ARGS", "Manage blob storage"
|
||||
subcommand "peer", Peer
|
||||
end
|
||||
|
|
|
@ -80,7 +80,13 @@ echo "=== Sign draft #2"
|
|||
echo "=== Dump the bundle"
|
||||
./pigeon-cli bundle create
|
||||
cat pigeon.bundle
|
||||
echo "=== ^ Dump the bundle"
|
||||
echo "=== end bundle dump"
|
||||
|
||||
echo "=== find a message"
|
||||
./pigeon-cli message find (./pigeon-cli message last)
|
||||
|
||||
echo "== find all messages"
|
||||
./pigeon-cli message find-all
|
||||
|
||||
echo "=== getting status:"
|
||||
./pigeon-cli status
|
||||
|
|
Loading…
Reference in New Issue