'use strict'

var path = require('path')

/* eslint-disable import/no-extraneous-dependencies */
var execa = require('execa')
var test = require('tape')
/* eslint-enable import/no-extraneous-dependencies */

var join = path.join

test('remark-cli', function(t) {
  t.plan(2)

  t.test('should show help on `--help`', function(st) {
    var bin = join('packages', 'remark-cli', 'cli.js')

    st.plan(1)

    execa(bin, ['--help']).then(function(result) {
      st.equal(
        result.stdout,
        [
          'Usage: remark [options] [path | glob ...]',
          '',
          '  CLI to process Markdown with remark using plugins',
          '',
          'Options:',
          '',
          '  -h  --help                output usage information',
          '  -v  --version             output version number',
          '  -o  --output [path]       specify output location',
          '  -r  --rc-path <path>      specify configuration file',
          '  -i  --ignore-path <path>  specify ignore file',
          '  -s  --setting <settings>  specify settings',
          '  -e  --ext <extensions>    specify extensions',
          '  -u  --use <plugins>       use plugins',
          '  -w  --watch               watch for changes and reprocess',
          '  -q  --quiet               output only warnings and errors',
          '  -S  --silent              output only errors',
          '  -f  --frail               exit with 1 on warnings',
          '  -t  --tree                specify input and output as syntax tree',
          '      --report <reporter>   specify reporter',
          '      --file-path <path>    specify path to process as',
          '      --tree-in             specify input as syntax tree',
          '      --tree-out            output syntax tree',
          '      --inspect             output formatted syntax tree',
          '      --[no-]stdout         specify writing to stdout (on by default)',
          '      --[no-]color          specify color in report (on by default)',
          '      --[no-]config         search for configuration files (on by default)',
          '      --[no-]ignore         search for ignore files (on by default)',
          '',
          'Examples:',
          '',
          '  # Process `input.md`',
          '  $ remark input.md -o output.md',
          '',
          '  # Pipe',
          '  $ remark < input.md > output.md',
          '',
          '  # Rewrite all applicable files',
          '  $ remark . -o'
        ].join('\n'),
        'should show help'
      )
    })
  })

  t.test('should show version on `--version`', function(st) {
    var bin = join('packages', 'remark-cli', 'cli.js')

    st.plan(2)

    execa(bin, ['--version']).then(function(result) {
      st.ok(
        /remark: \d+\.\d+\.\d+/.test(result.stdout),
        'should include remark version'
      )

      st.ok(
        /remark-cli: \d+\.\d+\.\d+/.test(result.stdout),
        'should include remark-cli version'
      )
    })
  })
})

@@ -716,24 +716,28 @@
             
+    
 output usage
@@ -786,24 +786,28 @@
             
+    
 output versi
@@ -853,24 +853,28 @@
 path%5D       
+  
+  
 specify outp
@@ -916,24 +916,28 @@
 -path %3Cpath%3E
+    
       specif
@@ -996,16 +996,20 @@
 h %3Cpath%3E
+    
   specif
@@ -1061,16 +1061,20 @@
 ettings%3E
+    
   specif
@@ -1121,24 +1121,28 @@
 ensions%3E    
+ 
+   
 specify exte
@@ -1189,16 +1189,20 @@
 %3E       
+  
+  
 use plug
@@ -1246,16 +1246,20 @@
         
+    
 watch fo
@@ -1315,32 +1315,36 @@
 t               
+    
 output only warn
@@ -1392,32 +1392,36 @@
 nt              
+    
 output only erro
@@ -1464,16 +1464,20 @@
         
+    
 exit wit
@@ -1525,32 +1525,36 @@
                 
+  
+  
 specify input an
@@ -1615,16 +1615,20 @@
 eporter%3E
+    
    speci
@@ -1672,24 +1672,28 @@
 -path %3Cpath%3E
+    
     specify 
@@ -1709,24 +1709,93 @@
 rocess as',%0A
+          '      --ignore-pattern %3Cglobs%3E  specify ignore patterns',%0A
           ' 
@@ -1813,32 +1813,36 @@
 -in             
+    
 specify input as
@@ -1891,24 +1891,28 @@
             
+    
 output synta
@@ -1955,24 +1955,28 @@
             
+ 
+   
 output forma
@@ -2025,32 +2025,36 @@
 %5Dstdout         
+    
 specify writing 
@@ -2112,32 +2112,36 @@
 %5Dcolor          
+   
+ 
 specify color in
@@ -2197,32 +2197,36 @@
 %5Dconfig         
+    
 search for confi
@@ -2289,32 +2289,36 @@
 %5Dignore         
+    
 search for ignor

Fix CLI help text test