source: frontend/node_modules/argparse/lib/help/added_formatters.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.6 KB
Line 
1'use strict';
2
3var util = require('util');
4
5// Constants
6var c = require('../const');
7
8var $$ = require('../utils');
9var HelpFormatter = require('./formatter.js');
10
11/**
12 * new RawDescriptionHelpFormatter(options)
13 * new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
14 *
15 * Help message formatter which adds default values to argument help.
16 *
17 * Only the name of this class is considered a public API. All the methods
18 * provided by the class are considered an implementation detail.
19 **/
20
21function ArgumentDefaultsHelpFormatter(options) {
22 HelpFormatter.call(this, options);
23}
24
25util.inherits(ArgumentDefaultsHelpFormatter, HelpFormatter);
26
27ArgumentDefaultsHelpFormatter.prototype._getHelpString = function (action) {
28 var help = action.help;
29 if (action.help.indexOf('%(defaultValue)s') === -1) {
30 if (action.defaultValue !== c.SUPPRESS) {
31 var defaulting_nargs = [ c.OPTIONAL, c.ZERO_OR_MORE ];
32 if (action.isOptional() || (defaulting_nargs.indexOf(action.nargs) >= 0)) {
33 help += ' (default: %(defaultValue)s)';
34 }
35 }
36 }
37 return help;
38};
39
40module.exports.ArgumentDefaultsHelpFormatter = ArgumentDefaultsHelpFormatter;
41
42/**
43 * new RawDescriptionHelpFormatter(options)
44 * new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
45 *
46 * Help message formatter which retains any formatting in descriptions.
47 *
48 * Only the name of this class is considered a public API. All the methods
49 * provided by the class are considered an implementation detail.
50 **/
51
52function RawDescriptionHelpFormatter(options) {
53 HelpFormatter.call(this, options);
54}
55
56util.inherits(RawDescriptionHelpFormatter, HelpFormatter);
57
58RawDescriptionHelpFormatter.prototype._fillText = function (text, width, indent) {
59 var lines = text.split('\n');
60 lines = lines.map(function (line) {
61 return $$.trimEnd(indent + line);
62 });
63 return lines.join('\n');
64};
65module.exports.RawDescriptionHelpFormatter = RawDescriptionHelpFormatter;
66
67/**
68 * new RawTextHelpFormatter(options)
69 * new ArgumentParser({formatterClass: argparse.RawTextHelpFormatter, ...})
70 *
71 * Help message formatter which retains formatting of all help text.
72 *
73 * Only the name of this class is considered a public API. All the methods
74 * provided by the class are considered an implementation detail.
75 **/
76
77function RawTextHelpFormatter(options) {
78 RawDescriptionHelpFormatter.call(this, options);
79}
80
81util.inherits(RawTextHelpFormatter, RawDescriptionHelpFormatter);
82
83RawTextHelpFormatter.prototype._splitLines = function (text) {
84 return text.split('\n');
85};
86
87module.exports.RawTextHelpFormatter = RawTextHelpFormatter;
Note: See TracBrowser for help on using the repository browser.