status.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var ArgumentParser, Base, Command, PackageJson, User, add_option_dict, env, format_fingerprint, iced, log, make_esc, session, __iced_k, __iced_k_noop,
  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. Base = require('./base').Base;
  9. log = require('../log');
  10. ArgumentParser = require('argparse').ArgumentParser;
  11. add_option_dict = require('./argparse').add_option_dict;
  12. PackageJson = require('../package').PackageJson;
  13. session = require('../session').session;
  14. make_esc = require('iced-error').make_esc;
  15. env = require('../env').env;
  16. log = require('../log');
  17. User = require('../user').User;
  18. format_fingerprint = require('pgp-utils').util.format_fingerprint;
  19. exports.Command = Command = (function(_super) {
  20. __extends(Command, _super);
  21. function Command() {
  22. return Command.__super__.constructor.apply(this, arguments);
  23. }
  24. Command.prototype.OPTS = {
  25. T: {
  26. alias: 'text',
  27. action: 'storeTrue',
  28. help: 'output in text format; default is JSON'
  29. }
  30. };
  31. Command.prototype.use_session = function() {
  32. return true;
  33. };
  34. Command.prototype.add_subcommand_parser = function(scp) {
  35. var name, opts, sub;
  36. opts = {
  37. help: "print current status"
  38. };
  39. name = "status";
  40. sub = scp.addParser(name, opts);
  41. add_option_dict(sub, this.OPTS);
  42. return [name];
  43. };
  44. Command.prototype.run = function(cb) {
  45. var d, esc, logged_in, me, obj, rp, un, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  46. __iced_k = __iced_k_noop;
  47. ___iced_passed_deferral = iced.findDeferral(arguments);
  48. esc = make_esc(cb, "Command::run");
  49. (function(_this) {
  50. return (function(__iced_k) {
  51. if ((un = env().get_username()) != null) {
  52. (function(__iced_k) {
  53. __iced_deferrals = new iced.Deferrals(__iced_k, {
  54. parent: ___iced_passed_deferral,
  55. filename: "/home/jacko/node-client/src/command/status.iced",
  56. funcname: "Command.run"
  57. });
  58. session.check(esc(__iced_deferrals.defer({
  59. assign_fn: (function() {
  60. return function() {
  61. return logged_in = arguments[0];
  62. };
  63. })(),
  64. lineno: 44
  65. })));
  66. __iced_deferrals._fulfill();
  67. })(function() {
  68. (function(__iced_k) {
  69. __iced_deferrals = new iced.Deferrals(__iced_k, {
  70. parent: ___iced_passed_deferral,
  71. filename: "/home/jacko/node-client/src/command/status.iced",
  72. funcname: "Command.run"
  73. });
  74. User.load_me({
  75. secret: false
  76. }, esc(__iced_deferrals.defer({
  77. assign_fn: (function() {
  78. return function() {
  79. return me = arguments[0];
  80. };
  81. })(),
  82. lineno: 45
  83. })));
  84. __iced_deferrals._fulfill();
  85. })(function() {
  86. var _ref;
  87. obj = {
  88. status: {
  89. configured: true,
  90. logged_in: logged_in
  91. },
  92. user: {
  93. name: un
  94. }
  95. };
  96. return __iced_k(typeof me !== "undefined" && me !== null ? (obj.user.key = {
  97. key_id: (_ref = me.key_id_64()) != null ? _ref.toUpperCase() : void 0,
  98. fingerprint: me.fingerprint() != null ? format_fingerprint(me.fingerprint(true)) : void 0
  99. }, (rp = me.list_remote_proofs()) != null ? obj.user.proofs = rp : void 0, (d = me.list_cryptocurrency_addresses()) != null ? obj.user.cryptocurrency = d : void 0) : void 0);
  100. });
  101. });
  102. } else {
  103. return __iced_k(obj = {
  104. status: {
  105. configured: false
  106. }
  107. });
  108. }
  109. });
  110. })(this)((function(_this) {
  111. return function() {
  112. _this.output(obj);
  113. return cb(null);
  114. };
  115. })(this));
  116. };
  117. Command.prototype.output_text = function(obj) {
  118. var ct, k, ko, rp, v, _results;
  119. if (obj.status.configured) {
  120. log.console.log("configged as " + obj.user.name);
  121. log.console.log(" * " + (obj.status.logged_in ? '' : 'NOT ') + "logged in");
  122. if ((ko = obj.user.key) != null) {
  123. log.console.log(" * Key ID: " + ko.key_id);
  124. log.console.log(" * Fingerprint: " + ko.fingerprint);
  125. }
  126. if ((rp = obj.user.proofs) != null) {
  127. log.console.log("Remote proofs:");
  128. for (k in rp) {
  129. v = rp[k];
  130. log.console.log(" * " + k + ": " + v);
  131. }
  132. }
  133. if ((ct = obj.user.cryptocurrency) != null) {
  134. log.console.log("Cryptocurrency Addresses:");
  135. _results = [];
  136. for (k in ct) {
  137. v = ct[k];
  138. _results.push(log.console.log(" * " + k + ": " + v));
  139. }
  140. return _results;
  141. }
  142. } else {
  143. return log.error("Not configured");
  144. }
  145. };
  146. Command.prototype.output = function(obj) {
  147. if (this.argv.text) {
  148. return this.output_text(obj);
  149. } else {
  150. return log.console.log(JSON.stringify(obj, null, " "));
  151. }
  152. };
  153. return Command;
  154. })(Base);
  155. }).call(this);