Added class to retrieve and store arguments
This commit is contained in:
@@ -30,7 +30,6 @@ public:
|
||||
void setBrightnessByPercentage();
|
||||
|
||||
std::vector<std::string> getOptions();
|
||||
//std::ofstream getStreamToOverwriteBrightness();
|
||||
|
||||
int getIncrement() const;
|
||||
int getDecrement() const;
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
|
||||
#include "AlterBrightness.h"
|
||||
#include "Brightness.h"
|
||||
#include"RetrieveArguments.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
|
||||
RetrieveArguments args{argc, argv};
|
||||
Brightness br{};
|
||||
if (argc == 3)
|
||||
{
|
||||
std::string control{*(argv + 1)};
|
||||
auto changeAmount = atoi(*(argv + 2));
|
||||
auto brightnessPercentage = atoi(*(argv + 2));
|
||||
auto control{args.argumentElements()[1]};
|
||||
auto changeAmount = args.argumentElements()[2];
|
||||
auto brightnessPercentage = args.argumentElements()[2];
|
||||
|
||||
br.grabBrightness();
|
||||
br.grabMaxBrightness();
|
||||
|
||||
|
||||
AlterBrightness ab{};
|
||||
ab.setIncrement(changeAmount);
|
||||
ab.setDecrement(changeAmount);
|
||||
ab.setPercentageBrightness(brightnessPercentage);
|
||||
ab.setIncrement(atoi(changeAmount.c_str()));
|
||||
ab.setDecrement(atoi(changeAmount.c_str()));
|
||||
ab.setPercentageBrightness(atoi(brightnessPercentage.c_str()));
|
||||
|
||||
ab.chooseChange((control));
|
||||
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef RETRIEVEARGUMENTS_H
|
||||
#define RETRIEVEARGUMENTS_H
|
||||
|
||||
#include<vector>
|
||||
#include<string>
|
||||
|
||||
class RetrieveArguments
|
||||
{
|
||||
public:
|
||||
RetrieveArguments() = default;
|
||||
RetrieveArguments(const int, char*[]);
|
||||
|
||||
void initilize(const int, char*[]);
|
||||
|
||||
std::vector<std::string> argumentElements() const;
|
||||
|
||||
private:
|
||||
std::vector<std::string> arguments;
|
||||
};
|
||||
#endif
|
||||
|
||||
RetrieveArguments::RetrieveArguments(const int amountOfArguments, char* argumentsFromInit[])
|
||||
{
|
||||
for (auto index=1; index!=amountOfArguments; ++index)
|
||||
{
|
||||
arguments.push_back(std::string{*(argumentsFromInit + index)});
|
||||
}
|
||||
}
|
||||
|
||||
void RetrieveArguments::initilize(const int amountOfArguments, char* argumentsFromInit[])
|
||||
{
|
||||
for (auto index=1; index!=amountOfArguments; ++index)
|
||||
arguments.push_back(std::string{*(argumentsFromInit + index)});
|
||||
}
|
||||
std::vector<std::string> RetrieveArguments::argumentElements() const
|
||||
{
|
||||
return arguments;
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
Hot.out: AlterBrightness.cpp AlterBrightness.h Main.cpp Brightness.cpp Brightness.h
|
||||
g++ AlterBrightness.cpp AlterBrightness.h Main.cpp Brightness.cpp Brightness.h -o Hot.out
|
||||
Hot.out: AlterBrightness.cpp AlterBrightness.h Main.cpp Brightness.cpp Brightness.h RetrieveArguments.h
|
||||
g++ AlterBrightness.cpp AlterBrightness.h Main.cpp Brightness.cpp Brightness.h RetrieveArguments.h -o Hot.out
|
||||
|
||||
Reference in New Issue
Block a user