sdk icon indicating copy to clipboard operation
sdk copied to clipboard

[dartdev] Allow using space between `-D` and variable

Open osaxma opened this issue 3 years ago • 0 comments

Note: Initially I thought this was an issue but it turns out it's working as expected -- so I updated it as a feature request.

  • Given main.dart:

    void main(List<String> args) {
      print(String.fromEnvironment('name', defaultValue: 'null'));
    }
    
  • Running the following:

    # 1-  does not work
    dart run --define name=osaxma bin/main.dart 
    dart run --define "name=osaxma" bin/main.dart 
    
    # 2- does work
    dart run --define=name=osaxma bin/main.dart
    dart run --define="name=osaxma" bin/main.dart 
    
    # 3- does not work
    dart run -D name=osaxma bin/main.dart 
    dart run -D "name=osaxma" bin/main.dart 
    
    # 4- does work when no space between flag and variable
    dart run -Dname=osaxma bin/main.dart 
    dart run -D"name=osaxma" bin/main.dart 
    
  • Result:

    null
    null
    
    osaxma
    osaxma
    
    null
    null
    
    osaxma
    osaxma
    

It'd be nice if case 1 & 3 worked. Especially case 3 because -Dname looks unfamiliar and unexpected (at least for the CLIs that I'm used to).

Version: Dart SDK version: 2.18.1 (stable) (Tue Sep 13 11:42:55 2022 +0200) on "macos_x64"

osaxma avatar Sep 20 '22 09:09 osaxma