carton icon indicating copy to clipboard operation
carton copied to clipboard

More commands for `carton sdk`

Open RayZhao1998 opened this issue 4 years ago • 4 comments

It seems that there's only one command install for carton sdk in current version.

If we have the situation of consisting multiple versions of sdk, I think we need to implement more commands for carton sdk.

  • carton sdk list: Show all installed sdks.
  • carton sdk use: Use a specific version of sdk you want.

If this proposal is reasonable, I'll be interested in implement it. :)

RayZhao1998 avatar Jul 01 '20 05:07 RayZhao1998

Hi @RayZhao1998, it is absolutely reasonable, thank you for creating this issue! One point that needs to be resolved is how carton sdk use would work. Would it record that version in the .swift-version file? A lot of toolchain managers allow specifying a "global" and a "local" toolchain, so maybe instead of carton sdk use it would be carton sdk global and carton sdk local? IDK, just spitballing here, mostly looking for a consensus on what the best user experience would be 🙂

MaxDesiatov avatar Jul 01 '20 11:07 MaxDesiatov

A lot of toolchain managers allow specifying a "global" and a "local" toolchain, so maybe instead of carton sdk use it would be carton sdk global and carton sdk local?

It make sense! we can use a flag such as -g representing "global", just like npm install -g or just use "global" in the command like yarn global add.

RayZhao1998 avatar Jul 01 '20 16:07 RayZhao1998

Yes, something like that, I personally prefer global and local subcommands as swiftenv already uses them. And since carton already picks up existing swiftenv installation, maybe carton should follow their convention to make it easier for developer to switch.

MaxDesiatov avatar Jul 01 '20 16:07 MaxDesiatov

TODO:

  • [x] carton sdk versions: show the list of installed sdks #21
  • [x] carton sdk local: show the local sdk version
  • [x] carton sdk local [version]: set the local sdk version
  • [ ] carton sdk global: show the global sdk version
  • [ ] carton sdk global [version]: set the global sdk version

carton sdk versions

This command will look up sdk installed in ~/.carton/sdk and ~/.swiftenv/versions. It'll display which version is set as local and global.

carton sdk local

In a project, the sdk version is saved in .swift-env. So we just need to look up the current local sdk version saved in .swift-env. Also when we want to set the local version of sdk, we just need to save the version to .swift-env.

carton sdk global

swiftenv save the global version of swift in ~/.swiftenv/version, maybe we can save our global version in ~/.carton/swift-version too.

RayZhao1998 avatar Jul 04 '20 06:07 RayZhao1998