A quick and dirty shell implementation for A.U.TH. (Operating systems Lab)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

46 lines
1.3 KiB

  1. /*!
  2. * \file
  3. * Snel.cpp
  4. * \brief A shell implementation for A.U.TH (Operating systems Lab)
  5. *
  6. * Created on: Feb, 2019
  7. * Author: Christos Choutouridis AEM: 8997
  8. * email : cchoutou@ece.auth.gr
  9. */
  10. #include "sequencer.h"
  11. int main(int argc, char* argv[]) try {
  12. snel::Sequencer seq{};
  13. std::string line, filtered;
  14. if (argc > 1) { // batch mode
  15. std::ifstream file(argv[1]);
  16. while (std::getline (file, line, '\n')) {
  17. //^ We use \n as delimiter. No further parsing here
  18. filtered = snel::filter(line); // simple filtering
  19. if (filtered == "quit")
  20. break;
  21. seq.parse(filtered).execute();
  22. }
  23. }
  24. else { // interactive mode
  25. std::cout << "Snel. A shell implementation for A.U.TH (OS Lab)." << std::endl;
  26. do {
  27. std::cout << "Choutouridis_8997>";
  28. std::getline (std::cin, line, '\n'); //< We use \n as delimiter. No parsing here
  29. filtered = snel::filter(line); // simple filtering
  30. if (filtered == "quit")
  31. break;
  32. seq.parse(filtered).execute();
  33. } while (1);
  34. }
  35. return 0;
  36. } catch (std::exception& e) {
  37. // we probably pollute the user's screen. Comment `cerr << ...` if you don't like it.
  38. // std::cerr << e.what() << '\n';
  39. exit(1);
  40. }