From 44ad3c8b36540c6b0b3144a21ac40310e163bb19 Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Sat, 11 Apr 2026 00:50:38 +0800 Subject: feat: initialize project structure with CMake build system, C++23 support, and core browser scaffolding --- src/main.cc | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/main.cc (limited to 'src/main.cc') diff --git a/src/main.cc b/src/main.cc new file mode 100644 index 0000000..0371cda --- /dev/null +++ b/src/main.cc @@ -0,0 +1,71 @@ +/* + * Ricochet - A minimalist CLI web browser for fast, distraction-free navigation. + * Copyright (C) 2026 Richard Qin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +#include "ricochet/core/browser.hh" +#include "ricochet/core/license.hh" + +namespace { + +void print_usage( std::string_view program_name ) +{ + std::cout << "Usage: " << program_name << " [URL]\n" + << "Example: " << program_name << " https://wikipedia.org\n"; +} + +} // namespace + +int main( int argc, char* argv[] ) +{ + const std::span args_view( argv, static_cast( argc ) ); + const std::vector args( args_view.begin(), args_view.end() ); + + ricochet::core::print_license_notice(); + + if ( args.size() < 2 ) { + std::cerr << "Error: No URL provided.\n"; + print_usage( args[0] ); + return 1; + } + + const std::string_view input = args[1]; + + if ( input == "show" ) { + if ( args[2] == "w" ) { + ricochet::core::show_warranty(); + } else if ( args[2] == "c" ) { + ricochet::core::show_copying(); + } else { + std::cerr << "Error: Invalid argument for show command.\n"; + print_usage( args[0] ); + return 1; + } + return 0; + } + + try { + return ricochet::core::Browser::run( input ); + } catch ( const std::exception& e ) { + std::cerr << "Critical Error: " << e.what() << "\n"; + return 1; + } +} \ No newline at end of file -- cgit v1.2.3