aboutsummaryrefslogtreecommitdiff
path: root/src/tests/csv.cpp
blob: 03e1df8c5a9dab02116d1eb3d4471686dc372860 (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
#include "bu/optparser.h"
#include "bu/file.h"
#include "bu/newline.h"
#include "bu/csvreader.h"
#include "bu/sio.h"

using namespace Bu;

class Options : public OptParser
{
public:
	Options( int argc, char *argv[] )
	{
		addOption( slot( this, &Options::onRead ), 'r', "read",
				"Read and display a csv file." );

		addHelpOption();

		parse( argc, argv );
	}

	int onRead( StrArray aArgs )
	{
		File fIn( aArgs[1], File::Read );
		NewLine nlIn( fIn );
		CsvReader rCsv( nlIn );
		while( !fIn.isEos() )
		{
			sio << rCsv.readLine() << sio.nl;
		}
		sio << sio.nl;
		return 1;
	}
};

int main( int argc, char *argv[] )
{
	Options opts( argc, argv );
	return 0;
}