clipboard support
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include "clip/clip.h"
|
||||
using namespace std;
|
||||
|
||||
string replacements[6][2] = {
|
||||
@@ -29,12 +30,16 @@ int help() {
|
||||
cout << "Options:" << endl;
|
||||
cout << " -p Read from stdin" << endl;
|
||||
cout << " -h Show this help message" << endl;
|
||||
cout << " -f Read from file" << endl;
|
||||
cout << " -o Write to file" << endl;
|
||||
cout << " -c Copy to clipboard" << endl;
|
||||
cout << " text Text to convert" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
string input, inputfile, outputfile;
|
||||
bool _stdin = false;
|
||||
bool _stdin = false, clipboard = false;
|
||||
|
||||
if (argc < 2) {
|
||||
cout << owo("No text provided") << endl << endl;
|
||||
@@ -55,6 +60,8 @@ int main(int argc, char *argv[]) {
|
||||
return help();
|
||||
} else if (i == argc-1) {
|
||||
input = string(argv[i]);
|
||||
} else if (string(argv[i]) == "-c") {
|
||||
clipboard = true;
|
||||
} else {
|
||||
cout << owo("Invalid argument: " + string(argv[i])) << endl << endl;
|
||||
help();
|
||||
@@ -109,6 +116,9 @@ int main(int argc, char *argv[]) {
|
||||
} else if (input != "") {
|
||||
if (outputfile != "") {
|
||||
*output << owo(input) << endl;
|
||||
} else if (clipboard) {
|
||||
clip::set_text(owo(input));
|
||||
cout << owo("Copied to clipboard") << endl;
|
||||
} else {
|
||||
cout << owo(input) << endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user