Finished Batch + Minor improvements

This commit is contained in:
2025-07-29 20:22:17 +02:00
parent f54a3ba309
commit f93c463647
8 changed files with 80 additions and 18 deletions

29
include/cmd/cmd_head.hpp Normal file
View File

@ -0,0 +1,29 @@
#pragma once
#include "cmd/cmd_base.hpp"
namespace fsh {
class CmdHead : public Command {
protected:
virtual void register_flags() override {
ArgFactory& factory = get_factory();
factory.add_rule<int>((std::string) "-n", true);
factory.add_input_rule();
}
virtual void run(std::istream& in, std::ostream& out, ArgManager& args) override {
std::string s;
std::string o;
int count = args.get<int>("-n").value();
while (std::getline(in, s)) {
if(count-- < 1) break;
o += s + "\n";
}
out << o;
}
};
}