int main(int argc, char *argv[]) { opt::options_description desc("Usage: "); opt::positional_options_description po; opt::variables_map vm; std::shared_ptr<cnote> cn; set_options(desc, po); if (!parse_command_line_options(desc, po, argc, argv, vm)) { std::cout << "See -h for usage." << std::endl; return -1; } parse_cnote_options(vm); cnote_parser parser; if (!parse_note_database(parser, opts.notes_db_.c_str())) return -1; if (vm.count("help")) { std::cout << desc << std::endl; return 0; } else if (vm.count("search")) { if (opts.debug_) std::cout << "Searching for: " << vm["search"].as<std::string>() << std::endl; print_note(parser, vm["search"].as<std::string>()); return 0; } else if (vm.count("list")) { list_notes(parser); return 0; } cnote_creator cc; cn = cc.create_note(); if (cn) { parser.save_note(cn); write_note_database(parser, opts.notes_db_.c_str()); } return 0; }
/*********************** Main **********************/ int main(int argc, char *argv[]) { setup_home(); int g = 0; int x = 0; int V = 0; int c = 0; int l = 0; int e = 0; int d = 0; int u = 0; int h = 0; int G = 0; int T = 0; int C = 0; int M = 0; int N = 0; char * group; char * label; char * content; int opt ; while((opt= getopt(argc,argv, "V(verbose)g:x(execute)c(create)l(list)e(echo):d(drop):u(edit):h(help)G(group):T(template):C(command)::M(macro)::N(note)::"))!= -1) { switch(opt) { case 'g': g=1; group = optarg; break; case 'V': V = 1; break; case 'x': x = 1; break; case 'c': c = 1; break; case 'l': l = 1; break; case 'e': e = 1; label = argv[optind]; break; case 'd': d = 1; label = argv[optind]; break; case 'u': u = 1; label = argv[optind]; break; case 'h': h = 1; break; case 'G': G = 1; label = argv[optind]; break; case 'T': T = 1; label = argv[optind]; break; case 'C': C = 1; label = argv[optind]; content = argv[optind+1]; break; case 'N': N = 1; label = argv[optind]; content = argv[optind+1]; break; default: puts("test"); break; } } if(g == 1) { if(c == 1) { if(G ==1) { create_group(label); //break; } else if(N == 1) { create_note(group, label, content); //break; } else if(C == 1) { create_command(label,group,content); //break; } else if(T == 1) { create_template_from_current(group,label); //break; } else { puts("Invalid Command"); return -1; } } if(e == 1) { if(N == 1) { echo_note(group,label); } else if( C == 1) { echo_command(label, group); } else if (T == 1) { echo_template(label, group); } } else if(l == 1) { if(N == 1) { list_notes(group); //break; } else if(C == 1) { list_commands(group); //break; } else if(T == 1) { list_templates(group); } else { puts("Invalid Command"); return -1; } } else if(x == 1) { if(C == 1) { execute_command(group,label); //break; } else if(T == 1) { execute_template(group,label); } else { puts("Invalid Command"); return -1; } } } else if(c == 1) { if(G == 1) { create_group(label); //break; } else { puts("Invalid Command"); return -1; } } else if(e == 1) { if(G == 1) { echo_group(label); } } return 0; }