decrypt.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var BufferInStream, BufferOutStream, Command, TrackSubSubCommand, add_option_dict, dv, env, iced, keypull, log, __iced_k, __iced_k_noop, _ref,
  4. __hasProp = {}.hasOwnProperty,
  5. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  6. iced = require('iced-runtime').iced;
  7. __iced_k = __iced_k_noop = function() {};
  8. dv = require('./decrypt_and_verify');
  9. add_option_dict = require('./argparse').add_option_dict;
  10. env = require('../env').env;
  11. _ref = require('iced-spawn'), BufferOutStream = _ref.BufferOutStream, BufferInStream = _ref.BufferInStream;
  12. TrackSubSubCommand = require('../tracksubsub').TrackSubSubCommand;
  13. log = require('../log');
  14. keypull = require('../keypull').keypull;
  15. exports.Command = Command = (function(_super) {
  16. __extends(Command, _super);
  17. function Command() {
  18. return Command.__super__.constructor.apply(this, arguments);
  19. }
  20. Command.prototype.add_subcommand_parser = function(scp) {
  21. var name, opts, sub;
  22. opts = {
  23. aliases: ["dec"],
  24. help: "decrypt a file"
  25. };
  26. name = "decrypt";
  27. sub = scp.addParser(name, opts);
  28. add_option_dict(sub, dv.Command.OPTS);
  29. add_option_dict(sub, {
  30. o: {
  31. alias: "output",
  32. help: "output to the given file"
  33. }
  34. });
  35. sub.addArgument(["file"], {
  36. nargs: '?'
  37. });
  38. return opts.aliases.concat([name]);
  39. };
  40. Command.prototype.do_output = function(out, cb) {
  41. var ___iced_passed_deferral, __iced_deferrals, __iced_k;
  42. __iced_k = __iced_k_noop;
  43. ___iced_passed_deferral = iced.findDeferral(arguments);
  44. (function(_this) {
  45. return (function(__iced_k) {
  46. if (_this.argv.base64) {
  47. return __iced_k(log.console.log(out.toString('base64')));
  48. } else {
  49. (function(__iced_k) {
  50. __iced_deferrals = new iced.Deferrals(__iced_k, {
  51. parent: ___iced_passed_deferral,
  52. filename: "/Users/max/src/keybase/node-client/src/command/decrypt.iced",
  53. funcname: "Command.do_output"
  54. });
  55. process.stdout.write(out, __iced_deferrals.defer({
  56. lineno: 35
  57. }));
  58. __iced_deferrals._fulfill();
  59. })(__iced_k);
  60. }
  61. });
  62. })(this)((function(_this) {
  63. return function() {
  64. return cb();
  65. };
  66. })(this));
  67. };
  68. Command.prototype.is_batch = function() {
  69. return !(this.argv.message != null) && !(this.argv.file != null);
  70. };
  71. Command.prototype.do_keypull = function(cb) {
  72. var err, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  73. __iced_k = __iced_k_noop;
  74. ___iced_passed_deferral = iced.findDeferral(arguments);
  75. (function(_this) {
  76. return (function(__iced_k) {
  77. __iced_deferrals = new iced.Deferrals(__iced_k, {
  78. parent: ___iced_passed_deferral,
  79. filename: "/Users/max/src/keybase/node-client/src/command/decrypt.iced",
  80. funcname: "Command.do_keypull"
  81. });
  82. keypull({
  83. stdin_blocked: _this.is_batch(),
  84. need_secret: true
  85. }, __iced_deferrals.defer({
  86. assign_fn: (function() {
  87. return function() {
  88. return err = arguments[0];
  89. };
  90. })(),
  91. lineno: 45
  92. }));
  93. __iced_deferrals._fulfill();
  94. });
  95. })(this)((function(_this) {
  96. return function() {
  97. _this._ran_keypull = true;
  98. return cb(err);
  99. };
  100. })(this));
  101. };
  102. Command.prototype.patch_gpg_args = function(args) {
  103. return args.push("--decrypt", "--yes");
  104. };
  105. Command.prototype.get_files = function(args) {
  106. var f;
  107. if ((f = this.argv.file) != null) {
  108. args.push(f);
  109. return true;
  110. } else {
  111. return false;
  112. }
  113. };
  114. return Command;
  115. })(dv.Command);
  116. }).call(this);