Skip to content

Add -h/--help flags support to symlink-project command #163

@wombatbuddy

Description

@wombatbuddy

Preliminary checklist

  • I am using the latest stable version of DDEV
  • I am using the latest stable version of this add-on

Expected Behavior

When executing the command with the -h --help flags:
ddev symlink-project -h

ddev symlink-project --help
The command should display help information including:

  • Command description
  • Usage syntax
  • Available flags and their descriptions
  • Usage examples.

Actual Behavior

Help information is not displayed. Instead, the command executes the symlink operation as if no flags were provided.

Steps To Reproduce

Execute the following command:
ddev symlink-project -h
or
ddev symlink-project --help

Anything else?

Problem 1

When executing the commands:
ddev symlink-project -h
ddev symlink-project --help
Help information is not displayed; instead, the command executes.

Problem 2

The documentation states:
Usage: symlink-project [flags] [args]
However, symlink_project.php is called without arguments.
To pass arguments properly, the "symlink-project" script should use:
php symlink_project.php "$@"
instead of:
php symlink_project.php

Problem 3

Even if we allow argument passing by using php symlink_project.php "$@" in the "symlink-project" script, the symlink_project.php script only accepts these flags:
-v --verbose
-c --copy
See: https://git.drupalcode.org/project/gitlab_templates/-/blob/main/scripts/symlink_project.php
Therefore, running:
ddev symlink-project -h
ddev symlink-project --help
would not display help information. Instead, we'd get the error message:
"Positional parameters are no longer used."

Problem 4

When executing the command with the -v --verbose flag, the output provides no more useful information than calling the command without the flag. This makes the flag pointless.

Proposed Solutions

Option 1

  1. Remove arguments and flags from the "Usage" section:
## Usage: symlink-project
## Example: "ddev symlink-project"
  1. To enable -h --help flag support, add this code at the beginning of the "symlink-project" script:
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
  echo "Description: Symlink project files into the configured location"
  echo "Usage: symlink-project"
  exit 0
fi

Option 2

  1. If the "Copy the project files instead of making symlinks" mode has a real use case, document the -c --copy flag in the "symlink-project" script like this:
## Usage: symlink-project [flags]
## Flags: -c/--copy (copy instead of symlink)
## Example: "ddev symlink-project" or "ddev symlink-project --copy"
  1. To enable -h --help flag support, add this code at the beginning of the "symlink-project" script:
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
  echo "Description: Symlink project files into the configured location"
  echo "Usage: symlink-project [flags]"
  echo "Flags:"
  echo "  -c, --copy       Copy files instead of symlinking"
  exit 0
fi
  1. To enable calling the "symlink-project" command with the -c, --copy flag, the "symlink-project" script should pass arguments to "symlink_project.php". Therefore, replace this line of code:
    php symlink_project.php
    with:
    php symlink_project.php "$@"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions