# # # add_dir "tests/automate_read_packets" # # add_file "tests/automate_read_packets/__driver__.lua" # content [75b2fcbfddb0c8cd731d172b14000b0ef86999a8] # # patch "cmd_packet.cc" # from [40b0b42404f7107752378b5c4b90298c352c091b] # to [ef074f179836c43a7b7f27cd890e03e73692afb1] # # patch "monotone.texi" # from [49e39037ce032c7b65fdf42e5fde18b6fb911735] # to [87f31849c40edc58d9de50e6c8493acf3c384d49] # ============================================================ --- tests/automate_read_packets/__driver__.lua 75b2fcbfddb0c8cd731d172b14000b0ef86999a8 +++ tests/automate_read_packets/__driver__.lua 75b2fcbfddb0c8cd731d172b14000b0ef86999a8 @@ -0,0 +1,13 @@ +mtn_setup() + +check(mtn("automate", "genkey", "address@hidden", "foopass"), 0, false, false) +check(mtn("pubkey", "address@hidden"), 0, true) +rename("stdout", "key_packet") +check(mtn("dropkey", "address@hidden"), 0, false, false) + +check(mtn("ls", "keys"), 0, true) +check(not qgrep("address@hidden", "stdout")) + +check(mtn("automate", "read_packets", readfile("key_packet")), 0) +check(mtn("ls", "keys"), 0, true) +check(qgrep("address@hidden", "stdout")) ============================================================ --- cmd_packet.cc 40b0b42404f7107752378b5c4b90298c352c091b +++ cmd_packet.cc ef074f179836c43a7b7f27cd890e03e73692afb1 @@ -146,7 +146,36 @@ namespace }; } +// Name : read_packets +// Arguments: +// packet-data +// Added in: 8.1 +// Purpose: +// Store public keys (and incidentally anything else that can be +// represented as a packet) into the database. +// Input format: +// The format of the packet-data argument is identical to the output +// of "mtn pubkey " (or other packet output commands). +// Output format: +// No output. +// Error conditions: +// Invalid input formatting. +CMD_AUTOMATE(read_packets, N_("PACKET-DATA"), + N_("Load the given packets into the database."), + "", + options::opts::none) +{ + N(args.size() == 1, + F("wrong argument count")); + database db(app); + key_store keys(app); + packet_db_writer dbw(db, keys); + + istringstream ss(idx(args,0)()); + read_packets(ss, dbw); +} + CMD(read, "read", "", CMD_REF(packet_io), "[FILE1 [FILE2 [...]]]", N_("Reads packets from files"), N_("If no files are provided, the standard input is used."), ============================================================ --- monotone.texi 49e39037ce032c7b65fdf42e5fde18b6fb911735 +++ monotone.texi 87f31849c40edc58d9de50e6c8493acf3c384d49 @@ -8905,6 +8905,32 @@ @section Automation @end table address@hidden mtn automate read_packets @var{packet-data} + address@hidden @strong address@hidden Arguments: + +A data packet, @var{packet-data}, as produced by @command{mtn pubkey @var{keyname}}. + address@hidden Added in: + +8.1 + address@hidden Purpose: + +Store public keys (and incidentally anything else that can be represented as +a packet) into the database. + address@hidden Output format: + +No output. + address@hidden Error conditions: + +An error will be produced if the argument is not a valid packet. + address@hidden table + @end ftable @page