File: Options.cpp

package info (click to toggle)
eln 1.5.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,876 kB
  • sloc: cpp: 26,606; perl: 796; python: 437; sh: 73; makefile: 32; xml: 8
file content (90 lines) | stat: -rw-r--r-- 2,566 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// webgrab/Options.cpp - This file is part of eln

/* eln 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.

   eln 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 eln.  If not, see <http://www.gnu.org/licenses/>.
*/

// Options.C

#include "Options.h"
#include <QApplication>
#include <stdio.h>
#include <stdlib.h>
#include <QCommandLineParser>
#include <QCommandLineOption>

Options::Options(QApplication const &app) {
  QCommandLineOption cli_page("p", "Produce paginated output");
  QCommandLineOption cli_tiny("t", "Tiny [160px]");
  QCommandLineOption cli_small("s", "Small [320px]");
  QCommandLineOption cli_medium("m", "Medium [640px]");
  QCommandLineOption cli_large("l", "Large [1280px]");
  QCommandLineParser cli;
  cli.setApplicationDescription("\n"
    "Webgrab is a utility to download webpages and save archival copies\n"
    "in pdf format.\n"
    "\n"
    "Webgrab can also create a (png) thumbnail of the first page of the\n"
    "downloaded pdf.\n"
    "\n"
    "More information is at https://danielwagenaar.net/eln.");
  cli.addHelpOption();
  cli.addVersionOption();
  cli.addPositionalArgument("url", "Webpage to archive", "url");
  cli.addPositionalArgument("out.pdf", "Output filename", "out.pdf");
  cli.addPositionalArgument("out.png", "Thumbnail filename", "[out.png]");
  cli.addOption(cli_page);
  cli.addOption(cli_tiny);
  cli.addOption(cli_small);
  cli.addOption(cli_medium);
  cli.addOption(cli_large);
                             
  cli.process(app);

  if (cli.isSet("l"))
    imSize = 1280;
  else if (cli.isSet("m"))
    imSize = 640;
  else if (cli.isSet("s"))
    imSize = 320;
  else if (cli.isSet("t"))
    imSize = 160;
  else
    imSize = 640;

  paginate = cli.isSet("p");

  QStringList args = cli.positionalArguments();

  if (args.size() < 2) {
    cli.showHelp();
  }

  url = args.takeFirst();
  if (url.startsWith("/"))
    url = "file://" + url;
  else if (url.startsWith("http:"))
    ;
  else if (url.startsWith("https:"))
    ;
  else if (url.startsWith("file:"))
    ;
  else
    url = "http://" + url;

 
  out = args;

  qDebug() << "Hello world";
}