Skip to content

feat: add dde-am fields support#282

Closed
xzl01 wants to merge 1 commit intolinuxdeepin:masterfrom
xzl01:master
Closed

feat: add dde-am fields support#282
xzl01 wants to merge 1 commit intolinuxdeepin:masterfrom
xzl01:master

Conversation

@xzl01
Copy link
Collaborator

@xzl01 xzl01 commented Jul 7, 2025

Log:

Summary by Sourcery

Add support for specifying arbitrary launch fields in dde-am, including a CLI option and proper DBus handling.

New Features:

  • Introduce a --fields/-f CLI option and accept values after "--" as launch fields
  • Implement Launcher::setFields and include m_fields in the D-Bus Launch call arguments

Enhancements:

  • Improve command-line parsing to gracefully handle "--" separators and strip known flags for positional arguments
  • Register QStringList as a complex D-Bus type to ensure proper serialization

@deepin-ci-robot
Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: xzl01

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai
Copy link

sourcery-ai bot commented Jul 7, 2025

Reviewer's Guide

This PR introduces support for launch fields in dde-am by enhancing the CLI parser to accept a new --fields option and arguments after “--”, refactoring positional-argument handling, and extending the Launcher class to store and pass these fields over D-Bus.

Sequence diagram for CLI argument parsing and field handling

sequenceDiagram
    actor User
    participant CLI as dde-am main
    participant Parser
    participant Launcher
    User->>CLI: Run dde-am --fields foo -- appId bar
    CLI->>Parser: Preprocess args (handle --, --fields)
    Parser->>CLI: Return parsed appId, action, envVars, fields
    CLI->>Launcher: setFields(fields)
    CLI->>Launcher: setEnvironmentVariables(envVars)
    CLI->>Launcher: setAction(action)
    CLI->>Launcher: run()
    Launcher->>D-Bus: Launch(appId, action, fields, envVars)
Loading

Updated class diagram for Launcher with fields support

classDiagram
    class Launcher {
        +void setAction(QString action)
        +void setLaunchedType(LaunchedType type)
        +void setEnvironmentVariables(QStringList envVars)
        +void setFields(QStringList fields)
        +DExpected<void> run()
        +static DExpected<QStringList> appIds()
        -QString m_path
        -QString m_action
        -LaunchedType m_launchedType
        -QStringList m_environmentVariables
        -QStringList m_fields
    }
Loading

File-Level Changes

Change Details Files
Enhanced CLI parsing to support --fields and arguments after “--”
  • Added new QCommandLineOption for --fields
  • Collected and split raw argv at “--” into options vs fields
  • Prioritized parser.parse on cleaned argument list
  • Appended --fields values and post-"--" tokens into a unified fields list
  • Refined positional-argument extraction by stripping known options
apps/dde-am/src/main.cpp
Extended Launcher API and D-Bus integration to handle fields
  • Registered QStringList for Qt and D-Bus marshalling
  • Added setFields setter and m_fields member
  • Injected m_fields into Launch() D-Bus method arguments
apps/dde-am/src/launcher.cpp
apps/dde-am/src/launcher.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

QCommandLineOption envOption(QStringList() << "e" << "env",
"Set environment variable, format: NAME=VALUE (can be used multiple times)", "env");
parser.addOption(envOption);
QCommandLineOption fieldsOption(QStringList() << "f" << "fields",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fields使用addPositionalArgument会有什么问题么?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那你不和action冲突了吗

void setAction(const QString &action);
void setLaunchedType(LaunchedType type);
void setEnvironmentVariables(const QStringList &envVars);
void setFields(const QStringList &fields); // 新增
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种注释不用了吧,或者改成有意义的,

@18202781743
Copy link
Contributor

@BLumia 讨论过,兼容action和支持field分开做可能比较好,
第一步,先将action位置参数添加为选项参数,保持位置参数的兼容,同时改动使用action的相关的项目(dde-daemon和dde-shell),
第二步,等am间隔几个版本后,再去去掉action位置参数的兼容,并添加field功能,

@deepin-bot
Copy link

deepin-bot bot commented Jul 10, 2025

TAG Bot

New tag: 1.2.33
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #283

@deepin-bot
Copy link

deepin-bot bot commented Jul 31, 2025

TAG Bot

New tag: 1.2.34
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #287

@xzl01 xzl01 closed this by deleting the head repository Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants