Compare commits

...

6 commits

Author SHA1 Message Date
Bruno BELANYI 74825f34a7 nix: use upstream 'clang-format' hook 2021-10-09 13:24:24 +02:00
Bruno BELANYI f8687ee5bd nix: bump inputs 2021-10-09 13:24:06 +02:00
Bruno BELANYI bc54c3a6f6 nix: use 'inputsFrom' 2021-10-08 15:46:27 +02:00
Bruno BELANYI 9d0f311598 nix: use current directory for 'pre-commit' hooks
The behaviour makes more sense when e.g: one modifies the clang-format
rules but has not committed them yet.
2021-10-08 15:30:53 +02:00
Bruno BELANYI 5002193c63 dragger: use actual argument parsing 2021-10-08 15:30:53 +02:00
Bruno BELANYI 66747de1bb clang-format: fix break of arguments 2021-10-08 15:27:57 +02:00
4 changed files with 28 additions and 14 deletions

View file

@ -7,4 +7,8 @@ Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
# Break after every argument or not at all
BinPackArguments: false
BinPackParameters: false
---

View file

@ -42,11 +42,11 @@
]
},
"locked": {
"lastModified": 1631170176,
"narHash": "sha256-RLN/kur2Kpxt0cJp0Fms8ixuGpT8IHX0OpeQ8u8f0X4=",
"lastModified": 1633726775,
"narHash": "sha256-imcgx7bHP0qzRNu31jknZAzze71pWnEbMbnBcZYxXMg=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "3ed0e618cebc1ff291c27b749cf7568959cac028",
"rev": "77b45d526e4dcc1f26ce449f5dc561f2e6eb5db6",
"type": "github"
},
"original": {

View file

@ -49,15 +49,12 @@
checks = {
pre-commit = pre-commit-hooks.lib.${system}.run {
src = self;
src = ./.;
hooks = {
clang-format = {
enable = true;
name = "clang-format";
entry = "${pkgs.clang-tools}/bin/clang-format -style=file -i";
types = [ "text" "c++" ];
language = "system";
types_or = [ "c++" ];
};
nixpkgs-fmt = {
@ -72,10 +69,9 @@
defaultPackage = packages.dragger;
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ ]
++ defaultPackage.nativeBuildInputs
++ defaultPackage.buildInputs
;
inputsFrom = with packages; [
dragger
];
inherit (checks.pre-commit) shellHook;
};

View file

@ -1,4 +1,5 @@
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#include <QDrag>
#include <QFile>
@ -9,10 +10,23 @@
int main(int argc, char* argv[]) {
QApplication app(argc, argv);
QApplication::setApplicationName("dragger");
QApplication::setApplicationVersion("0.1.0");
QCommandLineParser parser;
parser.setApplicationDescription("A CLI drag-and-drop tool");
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument(
"files",
QCoreApplication::translate("files", "files to drag-and-drop"),
"[FILES...]");
parser.process(app);
QList<QUrl> urls;
for (int i = 1; i < argc; ++i) {
QFileInfo file(QFile(argv[i]));
for (auto const& path : parser.positionalArguments()) {
QFileInfo file{QFile{path}};
if (file.exists()) {
urls << QUrl("file:" + file.absoluteFilePath());
} else {