Skip to content

Adding additional info utilities#104

Open
joshmeads wants to merge 2 commits intodeinsoftware:mainfrom
joshmeads:main
Open

Adding additional info utilities#104
joshmeads wants to merge 2 commits intodeinsoftware:mainfrom
joshmeads:main

Conversation

@joshmeads
Copy link
Copy Markdown

@joshmeads joshmeads commented Apr 4, 2024

Hey, this PR just adds some extra info methods that I needed personally for some CI pipelines. I've separated the data fetching logic from the rendering logic to avoid repeat work.

Hope it helps!

swpm --info --json will return the info spec in JSON format

> swpm --info --json`
{
  "_": "npm",
  "using": "npm",
  "error": null,
  "ready": true,
  "origin": "pinned",
  "volta": true,
  "versions": {
    "swpm": "2.6.0",
    "node": "20.9.0",
    "npm": "10.2.1"
  }
}

If you pass a value to info it'll pick that value back.

> swpm --info=using
npm

> swpm --info origin
pinned

> swpm --info versions.node
20.9.0

> swpm --info brokenSelection
Invalid value - brokenSelection doesn't match any available value
using:  npm 
origin: 📌 pinned 
volta:  ⚡ detected 

Versions:
swpm:   2.6.0
Node:   20.9.0
npm:    10.2.1

The final brokenSelection example will run exit(1)

No value renders the same CLI output as previous.

> swpm --info
using:  npm 
origin: 📌 pinned 
volta:  ⚡ detected 

Versions:
swpm:   2.6.0
Node:   20.9.0
npm:    10.2.1

@equiman
Copy link
Copy Markdown
Member

equiman commented Apr 4, 2024

Hi @joshmeads I'm actually running out of time, but I will try to take a look at it this weekend.

@equiman
Copy link
Copy Markdown
Member

equiman commented Apr 26, 2026

Hi @joshmeads,

First of all, I sincerely apologize for the long delay in responding to this PR. I haven't had much free time lately to dedicate to the project, but I'm finally back at it.

I want to let you know that I've planned a major release, v3.0.0, where I'll be implementing the functionality you proposed. However, I’ve decided to take a slightly different architectural approach: instead of using global flags like --info, I’m introducing a dedicated swpm config command.

This new command will provide the same diagnostic information and will include a --json flag that even allows querying specific properties (e.g., swpm config --json:using). This keeps the core CLI cleaner while offering even more flexibility for scripts.

I'll be closing this PR once the new version is merged, but I really appreciate your contribution and for bringing this need to my attention. It was the catalyst for this new feature!

Thanks for your patience and for being part of the community.

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