summaryrefslogtreecommitdiff
path: root/cli-tests/file/driver.cxx
blob: fe923ccd2d431a1833b55ef0c55113d209d099f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// file      : file/driver.cxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// license   : MIT; see accompanying LICENSE file

// Test argv_file_scanner.
//
#include <memory>
#include <string>
#include <iostream>

#include "test.hxx"

#undef NDEBUG
#include <cassert>

using namespace std;

int
main (int argc, char* argv[])
{
  try
  {
    string a (argc > 1 ? argv[1] : "");

    // Special modes.
    //
    // ---- <file>
    // --- <file>
    //
    unique_ptr<cli::scanner> s (
      a == "----" ? new cli::argv_file_scanner (argv[2], "--file") :
      a == "---"  ? new cli::argv_file_scanner (argv[2])           :
      new cli::argv_file_scanner (argc, argv, "--file"));

    while (s->more ())
      cout << s->next () << endl;
  }
  catch (const cli::exception& e)
  {
    cerr << e << endl;
  }
}