فهرست منبع

chore: better error reporting for parameters, highlighting --help usage. fixess #303 and should improve #275

Almamu 1 سال پیش
والد
کامیت
be0fc25e72

+ 0 - 31
.github/ISSUE_TEMPLATE/background-doesn-t-load-properly.md

@@ -1,31 +0,0 @@
----
-name: Background doesn't load properly
-about: Use this to report backgrounds that are not loading (cannot find files, black
-  image, effects not working, etc)
-title: "[BGFIX]"
-labels: bug
-assignees: Almamu
-
----
-
-**Wallpaper Engine Background(s)**
-
-Link(s) to the background(s) in the steam workshop or their background ID(s).
-
-**Console output**
-
-When a background cannot be loaded, it's usually due to some unexpected error that is logged into the terminal. Please attach the program's output so we can properly debug it if needed.
-
-**Screenshots**
-
-If you have any screenshot of it working on Windows that'll help so we can compare both outputs
-
-**Desktop (please complete the following information):**
- 
-- OS: [e.g. Arch Linux]
- - Desktop Environment: [e.g. GNOME, CINNAMON, KDE...]
- - Window Manager: [if in doubt, just leave it empty]
-
-**Additional context**
-
-Any additional information about your setup

+ 58 - 0
.github/ISSUE_TEMPLATE/bug-report.yml

@@ -0,0 +1,58 @@
+name: "Bug Report"
+description: "Report a bug or unexpected behavior."
+labels: [bug]
+body:
+  - type: markdown
+    attributes:
+      value: |
+        Please fill out this form to report a bug.
+  - type: input
+    id: summary
+    attributes:
+      label: Bug Summary
+      description: Briefly describe the bug.
+    validations:
+      required: true
+  - type: textarea
+    id: steps
+    attributes:
+      label: Steps to Reproduce
+      description: Step-by-step instructions to reproduce the bug.
+    validations:
+      required: true
+  - type: textarea
+    id: expected
+    attributes:
+      label: Expected Behavior
+    validations:
+      required: false
+  - type: textarea
+    id: actual
+    attributes:
+      label: Actual Behavior / Logs
+    validations:
+      required: false
+  - type: input
+    id: os
+    attributes:
+      label: Operating System and Version
+    validations:
+      required: true
+  - type: input
+    id: de
+    attributes:
+      label: Desktop Environment (GNOME, KDE, etc.)
+    validations:
+      required: true
+  - type: input
+    id: x11_wayland
+    attributes:
+      label: Display Server (X11/Wayland)
+    validations:
+      required: true
+  - type: textarea
+    id: extra
+    attributes:
+      label: Additional Context or Screenshots
+    validations:
+      required: false

+ 46 - 0
.github/ISSUE_TEMPLATE/compatibility-issue.yml

@@ -0,0 +1,46 @@
+name: "Wallpaper Compatibility Issue"
+description: "Report a problem with a specific Wallpaper Engine wallpaper."
+labels: [compatibility, wallpaper]
+body:
+  - type: input
+    id: wallpaper
+    attributes:
+      label: Wallpaper Name, URL or ID
+    validations:
+      required: true
+  - type: textarea
+    id: issue
+    attributes:
+      label: Describe the Issue
+    validations:
+      required: true
+  - type: textarea
+    id: expected
+    attributes:
+      label: Expected Behavior
+    validations:
+      required: false
+  - type: textarea
+    id: logs
+    attributes:
+      label: Logs or Crash Output
+    validations:
+      required: false
+  - type: input
+    id: os
+    attributes:
+      label: Operating System and Version
+    validations:
+      required: true
+  - type: input
+    id: de
+    attributes:
+      label: Desktop Environment (GNOME, KDE, etc.)
+    validations:
+      required: true
+  - type: input
+    id: x11_wayland
+    attributes:
+      label: Display Server (X11/Wayland)
+    validations:
+      required: true

+ 32 - 0
.github/ISSUE_TEMPLATE/feature-request.yml

@@ -0,0 +1,32 @@
+name: "Feature Request"
+description: "Propose a new feature or enhancement."
+labels: [enhancement]
+body:
+  - type: markdown
+    attributes:
+      value: |
+        Use this form to suggest new features or improvements.
+  - type: textarea
+    id: feature
+    attributes:
+      label: Describe the Feature
+    validations:
+      required: true
+  - type: textarea
+    id: problem
+    attributes:
+      label: Problem this Feature Addresses (if any)
+    validations:
+      required: false
+  - type: textarea
+    id: alternatives
+    attributes:
+      label: Alternatives Considered
+    validations:
+      required: false
+  - type: textarea
+    id: context
+    attributes:
+      label: Additional Context or Mockups
+    validations:
+      required: false

+ 38 - 0
.github/ISSUE_TEMPLATE/installation-help.yml

@@ -0,0 +1,38 @@
+name: "Installation/Usage Help"
+description: "Request help with installing or using linux-wallpaperengine."
+labels: [question, support]
+body:
+  - type: markdown
+    attributes:
+      value: |
+        Need help? Fill this out so we can assist you better.
+  - type: textarea
+    id: issue
+    attributes:
+      label: What are you trying to do, and what's the problem?
+    validations:
+      required: true
+  - type: textarea
+    id: attempted
+    attributes:
+      label: What have you tried so far?
+    validations:
+      required: false
+  - type: textarea
+    id: error_logs
+    attributes:
+      label: Errors or Log Output
+    validations:
+      required: false
+  - type: input
+    id: system
+    attributes:
+      label: OS, Desktop Environment, X11/Wayland
+    validations:
+      required: true
+  - type: input
+    id: install_method
+    attributes:
+      label: Installation Method (e.g., AUR, Flatpak, build from source)
+    validations:
+      required: true

+ 0 - 10
.github/ISSUE_TEMPLATE/other-issues.md

@@ -1,10 +0,0 @@
----
-name: Other issues
-about: Use this to report general issues with the software
-title: ''
-labels: ''
-assignees: Almamu
-
----
-
-

+ 22 - 0
.github/ISSUE_TEMPLATE/refactor.yml

@@ -0,0 +1,22 @@
+name: "Code Cleanup / Refactor"
+description: "Suggest internal improvements like refactoring or technical debt cleanup."
+labels: [refactor, maintenance]
+body:
+  - type: textarea
+    id: what
+    attributes:
+      label: What needs improvement?
+    validations:
+      required: true
+  - type: textarea
+    id: why
+    attributes:
+      label: Why is this necessary or beneficial?
+    validations:
+      required: false
+  - type: textarea
+    id: impact
+    attributes:
+      label: Potential Impact on Users
+    validations:
+      required: false

+ 32 - 28
src/WallpaperEngine/Application/CApplicationContext.cpp

@@ -255,44 +255,48 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) :
             "    Runs the background 2317494988 on two screens, one on HDMI-1 and the other on HDMI-2\n\n"
     );
 
-    program.parse_known_args (argc, argv);
+    try {
+        program.parse_known_args (argc, argv);
 
-    if (this->settings.general.defaultBackground.empty ()) {
-        throw std::runtime_error ("No default background specified. Either --bg/-b or <background id> must be specified");
-    }
+        if (this->settings.general.defaultBackground.empty ()) {
+            throw std::runtime_error ("At least one background ID must be specified");
+        }
 
-    this->settings.audio.volume = std::max(0, std::min (this->settings.audio.volume, 128));
-    this->settings.screenshot.delay = std::max (0, std::min (this->settings.screenshot.delay, 5));
+        this->settings.audio.volume = std::max(0, std::min (this->settings.audio.volume, 128));
+        this->settings.screenshot.delay = std::max (0, std::min (this->settings.screenshot.delay, 5));
 
-    // use std::cout on this in case logging is disabled, this way it's easy to look at what is running
-    std::stringbuf buffer;
-    std::ostream bufferStream (&buffer);
+        // use std::cout on this in case logging is disabled, this way it's easy to look at what is running
+        std::stringbuf buffer;
+        std::ostream bufferStream (&buffer);
 
-    bufferStream << "Running with: ";
+        bufferStream << "Running with: ";
 
-    for (int i = 0; i < argc; i ++) {
-        bufferStream << argv [i];
-        bufferStream << " ";
-    }
+        for (int i = 0; i < argc; i ++) {
+            bufferStream << argv [i];
+            bufferStream << " ";
+        }
 
-    std::cout << buffer.str() << std::endl;
-    // perform some extra validation on the inputs
-    this->validateAssets ();
-    this->validateScreenshot ();
+        std::cout << buffer.str() << std::endl;
+        // perform some extra validation on the inputs
+        this->validateAssets ();
+        this->validateScreenshot ();
 
-    // setup application state
-    this->state.general.keepRunning = true;
-    this->state.audio.enabled = this->settings.audio.enabled;
-    this->state.audio.volume = this->settings.audio.volume;
-    this->state.mouse.enabled = this->settings.mouse.enabled;
+        // setup application state
+        this->state.general.keepRunning = true;
+        this->state.audio.enabled = this->settings.audio.enabled;
+        this->state.audio.volume = this->settings.audio.volume;
+        this->state.mouse.enabled = this->settings.mouse.enabled;
 
 #if DEMOMODE
-    sLog.error ("WARNING: RUNNING IN DEMO MODE WILL STOP WALLPAPERS AFTER 5 SECONDS SO VIDEO CAN BE RECORDED");
-    // special settings for demomode
-    this->settings.render.maximumFPS = 30;
-    this->settings.screenshot.take = false;
-    this->settings.render.pauseOnFullscreen = false;
+        sLog.error ("WARNING: RUNNING IN DEMO MODE WILL STOP WALLPAPERS AFTER 5 SECONDS SO VIDEO CAN BE RECORDED");
+        // special settings for demomode
+        this->settings.render.maximumFPS = 30;
+        this->settings.screenshot.take = false;
+        this->settings.render.pauseOnFullscreen = false;
 #endif /* DEMOMODE */
+   } catch (const std::runtime_error& e) {
+       throw std::runtime_error (std::string (e.what()) + ". Use " + std::string (argv[0]) + " --help for more information");
+   }
 }
 
 int CApplicationContext::getArgc () const {

+ 38 - 33
src/main.cpp

@@ -20,47 +20,52 @@ void initLogging () {
 }
 
 int main (int argc, char* argv[]) {
-    // if type parameter is specified, this is a subprocess, so no logging should be enabled from our side
-    bool enableLogging = true;
-    std::string typeZygote = "--type=zygote";
-    std::string typeUtility = "--type=utility";
-
-    for (int i = 1; i < argc; i ++) {
-        if (strncmp (typeZygote.c_str(), argv[i], typeZygote.size()) == 0) {
-            enableLogging = false;
-            break;
-        } else if (strncmp (typeUtility.c_str(), argv[i], typeUtility.size()) == 0) {
-            enableLogging = false;
-            break;
+    try {
+        // if type parameter is specified, this is a subprocess, so no logging should be enabled from our side
+        bool enableLogging = true;
+        std::string typeZygote = "--type=zygote";
+        std::string typeUtility = "--type=utility";
+
+        for (int i = 1; i < argc; i ++) {
+            if (strncmp (typeZygote.c_str(), argv[i], typeZygote.size()) == 0) {
+                enableLogging = false;
+                break;
+            } else if (strncmp (typeUtility.c_str(), argv[i], typeUtility.size()) == 0) {
+                enableLogging = false;
+                break;
+            }
         }
-    }
 
-    if (enableLogging) {
-        initLogging ();
-    }
+        if (enableLogging) {
+            initLogging ();
+        }
 
-    WallpaperEngine::Application::CApplicationContext appContext (argc, argv);
+        WallpaperEngine::Application::CApplicationContext appContext (argc, argv);
 
-    // halt if the list-properties option was specified
-    if (appContext.settings.general.onlyListProperties)
-        return 0;
+        // halt if the list-properties option was specified
+        if (appContext.settings.general.onlyListProperties)
+            return 0;
 
-    app = new WallpaperEngine::Application::CWallpaperApplication (appContext);
+        app = new WallpaperEngine::Application::CWallpaperApplication (appContext);
 
-    // attach signals to gracefully stop
-    std::signal (SIGINT, signalhandler);
-    std::signal (SIGTERM, signalhandler);
-    std::signal (SIGKILL, signalhandler);
+        // attach signals to gracefully stop
+        std::signal (SIGINT, signalhandler);
+        std::signal (SIGTERM, signalhandler);
+        std::signal (SIGKILL, signalhandler);
 
-    // show the wallpaper application
-    app->show ();
+        // show the wallpaper application
+        app->show ();
 
-    // remove signal handlers before destroying app
-    std::signal (SIGINT, SIG_DFL);
-    std::signal (SIGTERM, SIG_DFL);
-    std::signal (SIGKILL, SIG_DFL);
+        // remove signal handlers before destroying app
+        std::signal (SIGINT, SIG_DFL);
+        std::signal (SIGTERM, SIG_DFL);
+        std::signal (SIGKILL, SIG_DFL);
 
-    delete app;
+        delete app;
 
-    return 0;
+        return 0;
+    } catch (const std::exception& e) {
+        std::cerr << e.what () << std::endl;
+        return 1;
+    }
 }