Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findDirectivesInScriptCommand trims quotes from custom command files, breaks help text of provided commands #3051

Closed
diegoe opened this issue Jun 15, 2021 · 2 comments

Comments

@diegoe
Copy link
Contributor

diegoe commented Jun 15, 2021

Describe the bug
In findDirectivesInScriptCommand, spaces, quotes, and double quotes, are trimmed from strings in the command description:

    for scanner.Scan() {
        line := scanner.Text()
        if strings.HasPrefix(line, "## ") && strings.Contains(line, ":") {
            line = strings.Replace(line, "## ", "", 1)
            parts := strings.SplitN(line, ":", 2)
            parts[1] = strings.Trim(parts[1], " \"'")
            directives[parts[0]] = parts[1]
        }
    }

This breaks the formatting of help lines in the default provided commands (example, cmd/ddev/cmd/global_dotddev_assets/commands/web/drush)

$ ddev drush --help
(...)
Examples:
  ddev drush uli" or "ddev drush sql-cli" or "ddev drush --version
(...)

Versus the source:

#ddev-generated
## Description: Run drush CLI inside the web container
## Usage: drush [flags] [args]
## Example: "ddev drush uli" or "ddev drush sql-cli" or "ddev drush --version"
## ProjectTypes: drupal7,drupal8,drupal9,backdrop
(...)

To Reproduce
Run commands like ddev drush --help

Expected behavior
String is passed as is, or at least the provided commands don't fall into this bug.

Version and configuration information (please complete the following information):

  • macOS Big Sur 10.4
  • Docker Desktop version 3.4.0
  • ddev version information (use ddev version)
DDEV-Local version	v1.17.5
architecture      	arm64
db                	drud/ddev-dbserver-mariadb-10.3:v1.17.3
dba               	phpmyadmin:5
ddev-ssh-agent    	drud/ddev-ssh-agent:v1.17.0
docker            	20.10.7
docker-compose    	1.29.2
os                	darwin
router            	drud/ddev-router:v1.17.3
web               	drud/ddev-webserver:v1.17.4

Additional context

@rfay
Copy link
Member

rfay commented Jun 15, 2021

Good eye!

Want to do a PR? You don't even need a development environment to work on it and test with gitpod. https://gitpod.io/#https://github.com/drud/ddev

More hints in https://github.com/drud/ddev/blob/master/docs/developers/building-contributing.md

diegoe added a commit to diegoe/ddev that referenced this issue Jun 17, 2021
In 2ff4f0b, triming was added for readability of file paths but the code
does not actually depend on quotes around paths. It only cares for
commas to differentiate multiple paths in a given directive.

Fixes: ddev#3051

This partially reverts:
    commit 2ff4f0b
    Author: Andreas Hager <3351175+andreashager@users.noreply.github.com>
    Date:   Tue Dec 29 05:47:40 2020 +0100

        Create new HeidiSQL command for Windows and WSL2 (ddev#2679)
diegoe added a commit to diegoe/ddev that referenced this issue Jun 17, 2021
In 2ff4f0b, triming was added for readability of file paths but the code
does not actually depend on quotes around paths. It only cares for
commas to differentiate multiple paths in a given directive.

This partially reverts:
    commit 2ff4f0b
    Author: Andreas Hager <3351175+andreashager@users.noreply.github.com>
    Date:   Tue Dec 29 05:47:40 2020 +0100

        Create new HeidiSQL command for Windows and WSL2 (ddev#2679)
diegoe added a commit to diegoe/ddev that referenced this issue Jun 17, 2021
In 2ff4f0b, trimming was added for readability of file paths but the code
does not actually depend on quotes around paths. It only cares for
commas to differentiate multiple paths in a given directive.

This partially reverts:
    commit 2ff4f0b
    Author: Andreas Hager <3351175+andreashager@users.noreply.github.com>
    Date:   Tue Dec 29 05:47:40 2020 +0100

        Create new HeidiSQL command for Windows and WSL2 (ddev#2679)
rfay pushed a commit to diegoe/ddev that referenced this issue Jul 12, 2021
In 2ff4f0b, trimming was added for readability of file paths but the code
does not actually depend on quotes around paths. It only cares for
commas to differentiate multiple paths in a given directive.

This partially reverts:
    commit 2ff4f0b
    Author: Andreas Hager <3351175+andreashager@users.noreply.github.com>
    Date:   Tue Dec 29 05:47:40 2020 +0100

        Create new HeidiSQL command for Windows and WSL2 (ddev#2679)
@rfay
Copy link
Member

rfay commented Aug 20, 2021

This was fixed in #3057

@rfay rfay closed this as completed Aug 20, 2021
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

No branches or pull requests

2 participants