summaryrefslogtreecommitdiff
path: root/src/tests/csv.cpp
blob: 96db7562a4ef5e780e231e60ad4518e883a3d7fe (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
43
#include "bu/optparser.h"
#include "bu/file.h"
#include "bu/newline.h"
#include "bu/csvreader.h"
#include "bu/buffer.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 );
		Buffer bIn( nlIn );
		CsvReader rCsv( bIn );
		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;
}