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

Add config get and dump commands. #5835

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

philderbeast
Copy link
Contributor

@philderbeast philderbeast commented Aug 23, 2022

See #5600.

  • Any changes that could be relevant to users have been recorded in ChangeLog.md.
  • The documentation has been updated, if necessary

Please don't merge yet as I would like to preserve the order of the fields when dumping the project as YAML.

> cabal run stack -- config dump-project
Up to date
drop-packages:
- cabal-install
extra-deps:
- hackage: hi-file-parser-0.1.3.0@sha256:b868e1bcb73fffe5963de6879f0a0a4c5ced97e08fc09c2c9428af884cdcaa74,2488
flags:
  stack:
    developer-mode: true
packages:
- .
resolver: nightly-2022-08-02
user-message: |
  If building Stack on macOS, you are advised to use stack-macos.yaml as the
  project-level configuration file, and command:

  stack --stack-yaml stack-macos.yaml build

  See that configuration file for further information.
> cat stack.yaml
# GHC 9.2.4
resolver: nightly-2022-08-02

packages:
- .

extra-deps:
# nightly-2022-08-02 provides hi-file-parser-0.1.2.0, which does not accomodate
# GHC 9.4.1
- hi-file-parser-0.1.3.0@sha256:b868e1bcb73fffe5963de6879f0a0a4c5ced97e08fc09c2c9428af884cdcaa74,2488

drop-packages:
# See https://github.com/commercialhaskell/stack/pull/4712
- cabal-install

docker:
  enable: false
  repo: psibi/alpine-haskell-stack:9.2.4

nix:
  # --nix on the command-line to enable.
  packages:
  - zlib
  - unzip

flags:
  stack:
    developer-mode: true

ghc-options:
  "$locals": -fhide-source-paths

user-message: |
  If building Stack on macOS, you are advised to use stack-macos.yaml as the
  project-level configuration file, and command:

  stack --stack-yaml stack-macos.yaml build

  See that configuration file for further information.

@mpilgrem mpilgrem marked this pull request as draft August 23, 2022 18:39
@mpilgrem
Copy link
Member

@philderbeast, given your request to not merge yet, I changed the status of the pull request to 'draft'.

@philderbeast
Copy link
Contributor Author

I've now got the order preserved in the YAML and also display the JSON in a human-readable layout also with field order preserved:

> cabal run stack -- config dump-project
# GHC 9.2.4
resolver: nightly-2022-08-02

packages:
- .

extra-deps:
# nightly-2022-08-02 provides hi-file-parser-0.1.2.0, which does not accomodate
# GHC 9.4.1
- hackage: hi-file-parser-0.1.3.0@sha256:b868e1bcb73fffe5963de6879f0a0a4c5ced97e08fc09c2c9428af884cdcaa74,2488

drop-packages:
# See https://github.com/commercialhaskell/stack/pull/4712
- cabal-install

flags:
  stack:
    developer-mode: true

user-message: |
  # --nix on the command-line to enable.
  If building Stack on macOS, you are advised to use stack-macos.yaml as the
  project-level configuration file, and command:


  stack --stack-yaml stack-macos.yaml build

  See that configuration file for further information.
> cabal run stack -- config dump-project --json
{
    "resolver": "nightly-2022-08-02",
    "packages": [
        "."
    ],
    "extra-deps": [
        {
            "hackage": "hi-file-parser-0.1.3.0@sha256:b868e1bcb73fffe5963de6879f0a0a4c5ced97e08fc09c2c9428af884cdcaa74,2488"
        }
    ],
    "drop-packages": [
        "cabal-install"
    ],
    "flags": {
        "stack": {
            "developer-mode": true
        }
    },
    "user-message": "If building Stack on macOS, you are advised to use stack-macos.yaml as the\nproject-level configuration file, and command:\n\nstack --stack-yaml stack-macos.yaml build\n\nSee that configuration file for further information.\n"
}

Get the project resolver.
Add config get commands.
Get project system-ghc and install-ghc.
Extract duplicated as logBool.
Show scope.
Don't log the key asked for.
Should have been NoReexec.
Get and Modify variants of scopeFlag help.
Dump the project's configuration.
Pipe to common functions for config list.
Add scope and distinguish what is being dumped.
Extract encodeDump* functions.
First pass at dump-project and dump-stack.
Separate project and stack dumps more.
Add DumpStackScope and --lens option.
Parse what is needed for the dump.
Fix typos and improve help string.
Allow for missing stack settings in the project.
Fix a typo, aronud.
Better explain effective scope.
Drop the --global option when dumping the project.
@mpilgrem
Copy link
Member

mpilgrem commented Sep 9, 2022

@philderbeast, I see the CI is passing. If this is no longer 'draft', the 'Ready for review' button will turn off draft status.

@mpilgrem
Copy link
Member

I've been thinking about your proposed new commands.

We have the existing stack config set <option> dealing with the 'setting' of Stack's YAML configuration (where supported).

You propose to introduce stack config get <option> dealing with the 'getting' of information about Stack's YAML configuration (where supported).

It seemed to me that the proposed stack config dump-* was also within the domain of 'getting' information about Stack's configuration. What about the following scheme?

stack config get <option>  # Gets the value of the identified Stack option (where supported)
stack config get all-project  # The equivalent of your `stack config dump-project`. Gets all currently applicable project-specific configuration options
stack config get all-global  # The equivalent of your `stack config dump-stack`. Gets all currently applicable non-project-specific configuration options.

On terminology, Stack's online documentation distinguishes between 'project-specific' options and 'non-project specific' options (the latter in either a 'project-level' YAML configuration file or a 'global' YAML configuration file). I think it is fine to call non-project specific options 'global options', for short.

@philderbeast
Copy link
Contributor Author

philderbeast commented Sep 10, 2022

@mpilgrem when I chose dump-* names, I was not sure whether I liked the names and thought of them as place holders. Something to come back to. Thanks for the suggestions. In testing I found some issues not related to this fix that I'd like to get to before merging around inserting extra blank lines on edit. Could be related to multiline strings with blank lines, see #5861.

@mpilgrem
Copy link
Member

@philderbeast, similar to my posts elsewhere, letting you know that I will release a new version of Stack soon, if you want to bring this pull request to a conclusion.

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.

2 participants