Skip to content

Commit

Permalink
add indication of DAML_SDK_VERSION for daml version (#7385)
Browse files Browse the repository at this point in the history
Fixes #7381.

```
$ alias daml=~/.daml/sdk/0.0.0/daml/daml
$ daml version
DAML SDK versions:
  0.0.0
  1.4.0
  1.5.0-snapshot.20200811.4959.0.bbc2fe56
  1.5.0-snapshot.20200818.5027.0.1b33d374
  1.5.0-snapshot.20200902.5118.0.2b3cf1b3  (default SDK version for new projects)
$ DAML_SDK_VERSION=invalid daml version
daml: Invalid value for environment variable DAML_SDK_VERSION.
  context: Determining SDK version and path.
  details: Invalid SDK version  "invalid": Failed reading: takeWhile1

$ DAML_SDK_VERSION=1.4.4 daml version
DAML SDK versions:
  0.0.0
  1.4.0
  1.4.4                                    (selected by env var DAML_SDK_VERSION, not installed)
  1.5.0-snapshot.20200811.4959.0.bbc2fe56
  1.5.0-snapshot.20200818.5027.0.1b33d374
  1.5.0-snapshot.20200902.5118.0.2b3cf1b3  (default SDK version for new projects)
$ DAML_SDK_VERSION=1.4.0 daml version
DAML SDK versions:
  0.0.0
  1.4.0                                    (selected by env var DAML_SDK_VERSION)
  1.5.0-snapshot.20200811.4959.0.bbc2fe56
  1.5.0-snapshot.20200818.5027.0.1b33d374
  1.5.0-snapshot.20200902.5118.0.2b3cf1b3  (default SDK version for new projects)
$ DAML_SDK_VERSION=1.5.0-snapshot.20200902.5118.0.2b3cf1b3 daml version
DAML SDK versions:
  0.0.0
  1.4.0
  1.5.0-snapshot.20200811.4959.0.bbc2fe56
  1.5.0-snapshot.20200818.5027.0.1b33d374
  1.5.0-snapshot.20200902.5118.0.2b3cf1b3  (selected by env var DAML_SDK_VERSION, default SDK version for new projects)
$
```

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
garyverhaegen-da authored Sep 14, 2020
1 parent ef67efb commit d966178
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions daml-assistant/exe/DA/Daml/Assistant.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import qualified DA.Service.Logger as L
import qualified DA.Service.Logger.Impl.Pure as L
import qualified DA.Service.Logger.Impl.GCP as L
import DA.Daml.Project.Config
import DA.Daml.Project.Consts (sdkVersionEnvVar)
import DA.Daml.Assistant.Types
import DA.Daml.Assistant.Env
import DA.Daml.Assistant.Command
import DA.Daml.Assistant.Version
import DA.Daml.Assistant.Install
import DA.Daml.Assistant.Util
import System.Environment (getArgs)
import System.Environment (getArgs, lookupEnv)
import System.FilePath
import System.Directory
import System.Process.Typed
Expand Down Expand Up @@ -181,6 +182,7 @@ runCommand env@Env{..} = \case
availableVersionsE <- tryAssistant $ refreshAvailableSdkVersions envDamlPath
defaultVersionM <- tryAssistantM $ getDefaultSdkVersion envDamlPath
projectVersionM <- mapM getSdkVersionFromProjectPath envProjectPath
envSelectedVersionM <- lookupEnv sdkVersionEnvVar
snapshotVersionsE <- tryAssistant $
if vSnapshots
then getAvailableSdkSnapshotVersions
Expand Down Expand Up @@ -212,7 +214,9 @@ runCommand env@Env{..} = \case
Right vs -> (`elem` vs)

versionAttrs v = catMaybes
[ "project SDK version from daml.yaml"
[ ("selected by env var " <> pack sdkVersionEnvVar)
<$ guard (Just (unpack $ versionToText v) == envSelectedVersionM)
, "project SDK version from daml.yaml"
<$ guard (Just v == projectVersionM && isJust envProjectPath)
, "default SDK version for new projects"
<$ guard (Just v == defaultVersionM && isNothing envProjectPath)
Expand Down

0 comments on commit d966178

Please sign in to comment.