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 --- diff --git a/.woodpecker/check.yml b/.woodpecker/check.yml new file mode 100644 index 0000000..921c363 --- /dev/null +++ b/.woodpecker/check.yml @@ -0,0 +1,31 @@ +labels: + type: exec + +pipeline: +- name: flake check + image: bash + commands: + - nix flake check + +- name: package check + image: bash + commands: + - nix build + +- name: notify + image: bash + secrets: + - source: matrix_roomid + target: room + - source: matrix_username + target: user + - source: matrix_password + target: pass + - source: matrix_homeserver + target: address + commands: + - nix run github:ambroisie/matrix-notifier + when: + status: + - failure + - success diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8aa2645 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [year] [fullname] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/dragger.pro b/dragger.pro index 6015b89..62c7379 100644 --- a/dragger.pro +++ b/dragger.pro @@ -1,3 +1,3 @@ -SOURCES = dragger.cc +SOURCES = src/dragger.cc CONFIG += qt QT += widgets diff --git a/flake.lock b/flake.lock index 00c49b4..37d0752 100644 --- a/flake.lock +++ b/flake.lock @@ -1,28 +1,65 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "locked": { - "lastModified": 1631561581, - "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", "owner": "numtide", "repo": "flake-utils", - "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", "type": "github" }, "original": { "owner": "numtide", - "ref": "master", + "ref": "main", "repo": "flake-utils", "type": "github" } }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1633329294, - "narHash": "sha256-0LpQLS4KMgxslMgmDHmxG/5twFlXDBW9z4Or1iOrCvU=", + "lastModified": 1680273054, + "narHash": "sha256-Bs6/5LpvYp379qVqGt9mXxxx9GSE789k3oFc+OAL07M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ee084c02040e864eeeb4cf4f8538d92f7c675671", + "rev": "3364b5b117f65fe1ce65a3cdd5612a078a3b31e3", "type": "github" }, "original": { @@ -32,21 +69,40 @@ "type": "github" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, "pre-commit-hooks": { "inputs": { + "flake-compat": "flake-compat", "flake-utils": [ "flake-utils" ], + "gitignore": "gitignore", "nixpkgs": [ "nixpkgs" - ] + ], + "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1631170176, - "narHash": "sha256-RLN/kur2Kpxt0cJp0Fms8ixuGpT8IHX0OpeQ8u8f0X4=", + "lastModified": 1680170909, + "narHash": "sha256-FtKU/edv1jFRr/KwUxWTYWXEyj9g8GBrHntC2o8oFI8=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "3ed0e618cebc1ff291c27b749cf7568959cac028", + "rev": "29dbe1efaa91c3a415d8b45d62d48325a4748816", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 42cfda1..7e5ca9b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,12 +1,12 @@ { - description = "A simple calculator"; + description = "A CLI drag-and-drop tool"; inputs = { flake-utils = { type = "github"; owner = "numtide"; repo = "flake-utils"; - ref = "master"; + ref = "main"; }; nixpkgs = { @@ -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; }; @@ -85,19 +81,12 @@ }; }) // { overlay = final: prev: { - dragger = with final; stdenv.mkDerivation { + dragger = with final; qt5.mkDerivation { pname = "dragger"; version = "0.1.0"; src = self; - buildInputs = [ - libsForQt5.qt5.qtbase - ]; - nativeBuildInputs = [ - libsForQt5.qt5.wrapQtAppsHook - ]; - configurePhase = '' qmake ''; @@ -106,6 +95,14 @@ mkdir -p $out/bin cp dragger $out/bin ''; + + meta = with lib; { + description = "A CLI drag-and-drop tool"; + homepage = "https://gitea.belanyi.fr/ambroisie/dragger"; + license = licenses.mit; + maintainers = with maintainers; [ ambroisie ]; + platforms = platforms.all; + }; }; }; }; diff --git a/dragger.cc b/src/dragger.cc similarity index 52% rename from dragger.cc rename to src/dragger.cc index 87c59e4..7c08b83 100644 --- a/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 {