From 66747de1bb019ff636c37977e4a8b618c1aa0cf4 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 8 Oct 2021 15:27:52 +0200 Subject: [PATCH 1/6] clang-format: fix break of arguments --- .clang-format | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.clang-format b/.clang-format index f47e7d6..22d4205 100644 --- a/.clang-format +++ b/.clang-format @@ -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 --- From 5002193c63f33695504f8682f32a17a583ecb9a0 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 8 Oct 2021 15:27:36 +0200 Subject: [PATCH 2/6] dragger: use actual argument parsing --- src/dragger.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/dragger.cc b/src/dragger.cc index 87c59e4..7c08b83 100644 --- a/src/dragger.cc +++ b/src/dragger.cc @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -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 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 { From 9d0f311598608ef5d86188c55080454a6f6817e2 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 8 Oct 2021 15:28:53 +0200 Subject: [PATCH 3/6] 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. --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 8a18a85..56c5c1c 100644 --- a/flake.nix +++ b/flake.nix @@ -49,7 +49,7 @@ checks = { pre-commit = pre-commit-hooks.lib.${system}.run { - src = self; + src = ./.; hooks = { clang-format = { From bc54c3a6f60a61aa92563846fe6613b50d141216 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 8 Oct 2021 15:46:27 +0200 Subject: [PATCH 4/6] nix: use 'inputsFrom' --- flake.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 56c5c1c..dc173c2 100644 --- a/flake.nix +++ b/flake.nix @@ -72,10 +72,9 @@ defaultPackage = packages.dragger; devShell = pkgs.mkShell { - nativeBuildInputs = with pkgs; [ ] - ++ defaultPackage.nativeBuildInputs - ++ defaultPackage.buildInputs - ; + inputsFrom = with packages; [ + dragger + ]; inherit (checks.pre-commit) shellHook; }; From f8687ee5bd397319a5af05feaaf2498abd0a6ee0 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 9 Oct 2021 13:24:06 +0200 Subject: [PATCH 5/6] nix: bump inputs --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 00c49b4..f54086e 100644 --- a/flake.lock +++ b/flake.lock @@ -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": { From 74825f34a777282ec7e153a6e57b7e95ca24a319 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 9 Oct 2021 13:24:24 +0200 Subject: [PATCH 6/6] nix: use upstream 'clang-format' hook --- flake.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index dc173c2..f39bfbf 100644 --- a/flake.nix +++ b/flake.nix @@ -54,10 +54,7 @@ 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 = {