Projects STRLCPY cfonts Commits 12a28b9a
🤬
  • ■ ■ ■ ■
    README.md
    skipped 19 lines
    20 20   
    21 21  <p align="center">This is a silly little command line tool for sexy fonts in the console. <strong>Give your cli some love.</strong></p>
    22 22   
    23  -## Platforms
     23 +## Implementations
    24 24   
    25 25  ### Rust
    26 26   
    skipped 450 lines
  • ■ ■ ■ ■ ■
    nodejs/README.md
    skipped 161 lines
    162 162   
    163 163  ## Release History
    164 164   
     165 +* 3.1.0 - Added support for -V flag fallback
    165 166  * 3.0.0 - Added rust library port, aligned APIs, added hex background colors, fixed minor alignment bugs, updated license from GPLv2 to GPLv3
    166 167  * 2.10.1 - bumped dependencies
    167 168  * 2.10.0 - bumped dependencies, added typescript definitions into npm bundle
    skipped 66 lines
  • ■ ■ ■ ■
    nodejs/package.json
    1 1  {
    2 2   "name": "cfonts",
    3 3   "description": "Sexy fonts for the console",
    4  - "version": "3.0.0",
     4 + "version": "3.1.0",
    5 5   "homepage": "https://github.com/dominikwilkowski/cfonts",
    6 6   "author": {
    7 7   "name": "Dominik Wilkowski",
    skipped 127 lines
  • ■ ■ ■ ■ ■ ■
    nodejs/src/AddShortcuts.js
    skipped 27 lines
    28 28   Object.keys(flatOptions).forEach((option) => {
    29 29   flatOptions[option]._name = option;
    30 30   flatOptions[flatOptions[option].short] = flatOptions[option];
     31 + if (flatOptions[option].fallback_shortcut) {
     32 + flatOptions[flatOptions[option].fallback_shortcut] = flatOptions[option];
     33 + }
    31 34   });
    32 35   
    33 36   return flatOptions;
    skipped 6 lines
  • ■ ■ ■ ■ ■ ■
    nodejs/src/ParseArgs.js
    skipped 38 lines
    39 39   parsedArgs[name] = inputOptions[option].default;
    40 40   });
    41 41   
    42  - if (inputArgs[2] === '--help' || inputArgs[2] === '-h') {
    43  - parsedArgs.help = true;
    44  - }
     42 + const args = inputArgs.splice(3); // the first two are node specific, the third is our text
    45 43   
    46  - if (inputArgs[2] === '--version' || inputArgs[2] === '-v') {
     44 + const options = AddShortcuts(inputOptions);
     45 + 
     46 + const version_options = options['-v'];
     47 + if (
     48 + inputArgs[2] === version_options._name ||
     49 + inputArgs[2] === version_options.short ||
     50 + inputArgs[2] === version_options.fallback_shortcut
     51 + ) {
    47 52   parsedArgs.version = true;
    48 53   }
    49 54   
    50  - const args = inputArgs.splice(3); // the first two are node specific, the third is our text
    51  - 
    52  - const options = AddShortcuts(inputOptions);
     55 + const help_options = options['-h'];
     56 + if (
     57 + inputArgs[2] === help_options._name ||
     58 + inputArgs[2] === help_options.short ||
     59 + inputArgs[2] === help_options.fallback_shortcut
     60 + ) {
     61 + parsedArgs.help = true;
     62 + }
    53 63   
    54 64   for (let index = 0; args.length > index; index++) {
    55 65   const option = options[args[index]];
    skipped 24 lines
  • ■ ■ ■ ■ ■ ■
    nodejs/src/constants.js
    skipped 176 lines
    177 177   description: 'Use to display the version of cfonts',
    178 178   example: '--version',
    179 179   short: '-v',
     180 + fallback_shortcut: '-V',
    180 181   default: false,
    181 182   },
    182 183   '--help': {
    183 184   description: 'Use to display this help',
    184 185   example: '--help',
    185 186   short: '-h',
     187 + fallback_shortcut: false,
    186 188   default: false,
    187 189   },
    188 190   '--font': {
    skipped 2 lines
    191 193   .map((font) => FONTFACES[font])
    192 194   .join(', ')} ][green-close]`,
    193 195   short: '-f',
     196 + fallback_shortcut: false,
    194 197   options: Object.keys(FONTFACES).map((color) => FONTFACES[color]),
    195 198   default: 'block',
    196 199   },
    skipped 3 lines
    200 203   .map((color) => COLORS[color])
    201 204   .join(', ')}, #ff8800, hex-colors etc... ][green-close]`,
    202 205   short: '-c',
     206 + fallback_shortcut: false,
    203 207   options: true,
    204 208   default: 'system',
    205 209   },
    skipped 3 lines
    209 213   .map((bgcolor) => BGCOLORS[bgcolor])
    210 214   .join(', ')} ][green-close]`,
    211 215   short: '-b',
     216 + fallback_shortcut: false,
    212 217   options: Object.keys(BGCOLORS).map((color) => BGCOLORS[color]),
    213 218   default: 'transparent',
    214 219   },
    skipped 1 lines
    216 221   description: 'Use to align your text output',
    217 222   example: `--align [green-open][ ${ALIGNMENT.join(', ')} ][green-close]`,
    218 223   short: '-a',
     224 + fallback_shortcut: false,
    219 225   options: ALIGNMENT,
    220 226   default: 'left',
    221 227   },
    skipped 1 lines
    223 229   description: 'Use to define your letter spacing',
    224 230   example: '--letter-spacing 2',
    225 231   short: '-l',
     232 + fallback_shortcut: false,
    226 233   options: true,
    227 234   default: undefined,
    228 235   },
    skipped 1 lines
    230 237   description: 'Use to define your line height',
    231 238   example: '--line-height 5',
    232 239   short: '-z',
     240 + fallback_shortcut: false,
    233 241   options: true,
    234 242   default: undefined,
    235 243   },
    skipped 1 lines
    237 245   description: 'Use to disable the padding around your output',
    238 246   example: '--spaceless',
    239 247   short: '-s',
     248 + fallback_shortcut: false,
    240 249   default: false,
    241 250   },
    242 251   '--max-length': {
    243 252   description: 'Use to define the amount of maximum characters per line',
    244 253   example: '--max-length 10',
    245 254   short: '-m',
     255 + fallback_shortcut: false,
    246 256   options: true,
    247 257   default: 0,
    248 258   },
    skipped 1 lines
    250 260   description: 'Use to define a start and end color of a gradient',
    251 261   example: '--gradient red,blue,green',
    252 262   short: '-g',
     263 + fallback_shortcut: false,
    253 264   options: true,
    254 265   default: false,
    255 266   },
    skipped 1 lines
    257 268   description: 'Use to define that a gradient is applied independently for each line',
    258 269   example: '--gradient red,blue --independent-gradient',
    259 270   short: '-i',
     271 + fallback_shortcut: false,
    260 272   default: false,
    261 273   },
    262 274   '--transition-gradient': {
    263 275   description: 'Use to define that a gradient is a transition between the colors',
    264 276   example: '--gradient red,blue,green --transition-gradient',
    265 277   short: '-t',
     278 + fallback_shortcut: false,
    266 279   default: false,
    267 280   },
    268 281   '--env': {
    269 282   description: 'Use to define what environment you run CFonts in.',
    270 283   example: `--env [green-open][ "node", "browser" ][green-close]`,
    271 284   short: '-e',
     285 + fallback_shortcut: false,
    272 286   options: true,
    273 287   default: 'node',
    274 288   },
    skipped 1 lines
    276 290   description: 'Use to enable debug mode',
    277 291   example: '--debug',
    278 292   short: '-d',
     293 + fallback_shortcut: false,
    279 294   default: false,
    280 295   },
    281 296   '--debug-level': {
    282 297   description: 'Use to define the debug level. The higher, the less debug infos',
    283 298   example: '--debug-level 2',
    284 299   short: '-x',
     300 + fallback_shortcut: false,
    285 301   options: true,
    286 302   default: 1,
    287 303   },
    skipped 16 lines
  • ■ ■ ■ ■ ■ ■
    nodejs/test/unit/AddShortcuts.spec.js
    skipped 9 lines
    10 10   const input = {
    11 11   one: {
    12 12   description: 'desc value',
     13 + fallback_shortcut: false,
    13 14   short: 'oneshort',
    14 15   },
    15 16   two: {
    16 17   description: 'desc value',
     18 + fallback_shortcut: 'twofallback',
    17 19   short: 'twoshort',
    18 20   },
    19 21   };
    skipped 3 lines
    23 25   _name: 'one',
    24 26   description: 'desc value',
    25 27   short: 'oneshort',
     28 + fallback_shortcut: false,
    26 29   },
    27 30   oneshort: {
    28 31   _name: 'one',
    29 32   description: 'desc value',
    30 33   short: 'oneshort',
     34 + fallback_shortcut: false,
    31 35   },
    32 36   two: {
    33 37   _name: 'two',
    34 38   description: 'desc value',
    35 39   short: 'twoshort',
     40 + fallback_shortcut: 'twofallback',
    36 41   },
    37 42   twoshort: {
    38 43   _name: 'two',
    39 44   description: 'desc value',
    40 45   short: 'twoshort',
     46 + fallback_shortcut: 'twofallback',
     47 + },
     48 + twofallback: {
     49 + _name: 'two',
     50 + description: 'desc value',
     51 + short: 'twoshort',
     52 + fallback_shortcut: 'twofallback',
    41 53   },
    42 54   };
    43 55   
    skipped 3 lines
  • ■ ■ ■ ■ ■ ■
    nodejs/test/unit/Cli.spec.js
    skipped 27 lines
    28 28  });
    29 29   
    30 30  const options = {
     31 + '--version': {
     32 + _name: 'version',
     33 + short: '-v',
     34 + fallback_shortcut: '-V',
     35 + },
     36 + '--help': {
     37 + _name: 'help',
     38 + short: '-h',
     39 + fallback_shortcut: false,
     40 + },
    31 41   '--1': {
     42 + _name: '--1',
    32 43   description: 'desc value 1',
    33 44   short: '-1',
     45 + fallback_shortcut: false,
    34 46   options: true,
    35 47   default: '2',
    36 48   },
    37 49   '--2': {
     50 + _name: '--2',
    38 51   description: 'desc value 2',
    39 52   short: '-2',
     53 + fallback_shortcut: false,
    40 54   options: ['one', 'two', 'three'],
    41 55   default: 'one',
    42 56   },
    43 57   '--3': {
     58 + _name: '--3',
    44 59   description: 'desc value 3',
    45 60   short: '-3',
     61 + fallback_shortcut: false,
    46 62   default: false,
    47 63   },
    48 64   '--colors': {
     65 + _name: '--colors',
    49 66   description: 'desc colors',
    50 67   short: '-c',
     68 + fallback_shortcut: false,
    51 69   options: true,
    52 70   default: 'system',
    53 71   },
    skipped 204 lines
  • ■ ■ ■ ■ ■ ■
    nodejs/test/unit/ParseArgs.spec.js
    skipped 8 lines
    9 9   
    10 10  test(`ParseArgs - Return defaults without arguments`, () => {
    11 11   const options = {
     12 + '--version': {
     13 + _name: 'version',
     14 + short: '-v',
     15 + fallback_shortcut: '-V',
     16 + },
     17 + '--help': {
     18 + _name: 'help',
     19 + short: '-h',
     20 + fallback_shortcut: false,
     21 + },
    12 22   '--1': {
    13 23   description: 'desc value 1',
    14 24   short: '-1',
    skipped 50 lines
    65 75   
    66 76  test(`ParseArgs - Parse out variables no matter the order`, () => {
    67 77   const options = {
     78 + '--version': {
     79 + _name: 'version',
     80 + short: '-v',
     81 + fallback_shortcut: '-V',
     82 + },
     83 + '--help': {
     84 + _name: 'help',
     85 + short: '-h',
     86 + fallback_shortcut: false,
     87 + },
    68 88   '--1': {
    69 89   description: 'desc value 1',
    70 90   short: '-1',
    skipped 27 lines
    98 118   
    99 119  test(`ParseArgs - Ignore flags not in the options`, () => {
    100 120   const options = {
     121 + '--version': {
     122 + _name: 'version',
     123 + short: '-v',
     124 + fallback_shortcut: '-V',
     125 + },
     126 + '--help': {
     127 + _name: 'help',
     128 + short: '-h',
     129 + fallback_shortcut: false,
     130 + },
    101 131   '--1': {
    102 132   description: 'desc value 1',
    103 133   short: '-1',
    skipped 25 lines
    129 159   
    130 160  test(`ParseArgs - Help flag can be on text place`, () => {
    131 161   const options = {
     162 + '--version': {
     163 + _name: 'version',
     164 + short: '-v',
     165 + fallback_shortcut: '-V',
     166 + },
     167 + '--help': {
     168 + _name: 'help',
     169 + short: '-h',
     170 + fallback_shortcut: false,
     171 + },
    132 172   '--1': {
    133 173   description: 'desc value 1',
    134 174   short: '-1',
    skipped 35 lines
    170 210   
    171 211  test(`ParseArgs - Version flag can be on text place`, () => {
    172 212   const options = {
     213 + '--version': {
     214 + _name: 'version',
     215 + short: '-v',
     216 + fallback_shortcut: '-V',
     217 + },
     218 + '--help': {
     219 + _name: 'help',
     220 + short: '-h',
     221 + fallback_shortcut: false,
     222 + },
    173 223   '--1': {
    174 224   description: 'desc value 1',
    175 225   short: '-1',
    skipped 36 lines
  • ■ ■ ■ ■
    rust/Cargo.lock
    skipped 20 lines
    21 21   
    22 22  [[package]]
    23 23  name = "cfonts"
    24  -version = "1.0.1"
     24 +version = "1.0.2"
    25 25  dependencies = [
    26 26   "enable-ansi-support",
    27 27   "exitcode",
    skipped 265 lines
  • ■ ■ ■ ■
    rust/Cargo.toml
    1 1  [package]
    2 2  name = "cfonts"
    3  -version = "1.0.1"
     3 +version = "1.0.2"
    4 4  edition = "2021"
    5 5  authors = ["Dominik Wilkowski <[email protected]>"]
    6 6  license = "GPL-3.0-or-later"
    skipped 23 lines
  • ■ ■ ■ ■ ■
    rust/README.md
    skipped 133 lines
    134 134   
    135 135  ## Release History
    136 136   
     137 +* 1.0.2 - Fixed help and version flags in first position
    137 138  * 1.0.1 - Fixed font loading
    138 139  * 1.0.0 - Public release of rust API
    139 140  * 0.1.0 - alpha test
    skipped 7 lines
  • ■ ■ ■ ■ ■ ■
    rust/src/args.rs
    skipped 171 lines
    172 172   ));
    173 173   }
    174 174   
     175 + let version_options = options_lookup.get("-v").unwrap();
     176 + if my_args[1] == *version_options.shortcut.to_string()
     177 + || my_args[1] == *version_options.name.to_string()
     178 + || my_args[1] == *version_options.fallback_shortcut.to_string()
     179 + {
     180 + options.version = true;
     181 + }
     182 + 
     183 + let help_options = options_lookup.get("-h").unwrap();
     184 + if my_args[1] == *help_options.shortcut.to_string() || my_args[1] == *help_options.name.to_string() {
     185 + options.help = true;
     186 + }
     187 + 
    175 188   // our text to be converted
    176 189   options.text = my_args[1].clone();
    177 190   
    skipped 340 lines
  • ■ ■ ■ ■ ■ ■
    rust/tests/args_test.rs
    skipped 90 lines
    91 91   }
    92 92   
    93 93   #[test]
     94 + fn args_parse_version_flags() {
     95 + let mut options = Options::default();
     96 + options.version = true;
     97 + options.text = String::from("-v");
     98 + assert_eq!(parse(vec!["path/to/bin".to_string(), "-v".to_string()]).unwrap(), options);
     99 + options.text = String::from("-V");
     100 + assert_eq!(parse(vec!["path/to/bin".to_string(), "-V".to_string()]).unwrap(), options);
     101 + options.text = String::from("--version");
     102 + assert_eq!(parse(vec!["path/to/bin".to_string(), "--version".to_string()]).unwrap(), options);
     103 + }
     104 + 
     105 + #[test]
     106 + fn args_parse_help_flags() {
     107 + let mut options = Options::default();
     108 + options.help = true;
     109 + options.text = String::from("-h");
     110 + assert_eq!(parse(vec!["path/to/bin".to_string(), "-h".to_string()]).unwrap(), options);
     111 + options.text = String::from("--help");
     112 + assert_eq!(parse(vec!["path/to/bin".to_string(), "--help".to_string()]).unwrap(), options);
     113 + }
     114 + 
     115 + #[test]
    94 116   fn args_parse_boolean_flags() {
    95 117   let mut options = Options::default();
    96 118   options.text = String::from("my text");
    skipped 1723 lines
Please wait...
Page is in error, reload to recover