#include "ndir.h"
#include "nobject.h"
#include "nstring.h"
#include "ngetopt.h"
#include "noutput.h"
#include "nlist.h"
class DirInfo {
public:
DirInfo(void) {
}
bool setPath(const NOpt<DirInfo> &opt) {
m_path = opt.getValues().at(0);
return true;
}
int run(void) {
NDir dir(m_path);
NList<NString> contents;
contents = dir.getContents();
for (nuint64 i = 0; i < contents.size(); i++) {
NMessage::print() << "Entry " << i << " = " <<
contents.at(i);
}
return 0;
}
private:
NString m_path;
};
void setup_opts(NGetOpt<DirInfo> *opts) {
opts->add("h", "help", false, "Display the help for this program", NULL);
opts->add("p", "path", true, "The path to check",
&DirInfo::setPath);
}
int main(int argc, char **argv) {
DirInfo app;
NGetOpt<DirInfo> opts(argc, argv, &app, 1);
setup_opts(&opts);
try {
if (opts.proccess()) {
app.run();
}
}
catch (NException &e) {
NWarning::print() << e.getDescription();
exit(1);
}
return 0;
}