dcli
  • Introduction
  • What does DCli do?
  • Install DCli
    • Installing on Windows
  • Writing your first CLI app
  • Add DCli to your project
  • pub.dev
  • github
  • Dart basics
    • Dart lambda functions
    • Function Arguments
    • Futures
    • stdin/stdout/stderr a primer
  • Tour
    • Overview
    • Using DCli functions
    • User input
      • Ask Validators
    • Displaying information
    • Managing Files And Directories
    • Environment variables
    • Calling apps
    • Redirecting output
    • Command Line Arguments
    • Paths
    • Glob Expansion
    • Piping
    • Locking
    • Fetch
    • The evils of CD
    • Assets/Resources
    • Cross Platform
      • Posix
      • Windows
      • Docker
        • Detecting Docker
        • Add DCli to a Docker Container
        • Example DCli app in Docker
  • Elevated Privileges
    • Sudo
  • Performance
  • Dependency Management
    • Dependency Management
    • Pubspec Managment
  • DCli Tools
    • DCli tools
    • Use a shebang #!
    • DCli Compile
    • DCli Clean
    • DCli Create
    • DCli Doctor
    • DCli Install
    • DCli Run
    • DCli Warmup
    • DCli Pack
    • Upgrade DCli
  • Internal Workings
    • Internal Workings
    • waitForEx
  • Contributing
    • Creating a release
    • Running Unit tests
    • Implemention support for a shell
    • Templates
  • References
  • Examples
    • Projects
    • Code
      • hello world.
      • dcompress
      • dpath
      • dmysql
      • dshell
      • dwhich
      • dipaddr
      • gnome launcher
  • Articles
    • build CLI apps in dart - part 1
    • build CLI apps in dart - part 2
    • Dealing with permissions
    • 3rd Party console packages
  • Dart on Linux - the perfect CLI tooling
  • Improving your build environment
    • Existing tooling
    • Building with Dart
    • A home for your build tools
  • Olivier Revial - CLI apps made easy
  • Video: package of the week
Powered by GitBook
On this page
  • DCli and futures
  • Just ignore Futures
  • How DCli manages futures

Was this helpful?

  1. Dart basics

Futures

DCli and futures

if your not a Dart programmer (yet) one of the most difficult things about Dart are Futures. If you are familiar with Javascript then a Future is the equivalent of a Promise.

Just ignore Futures

If your not familiar with Dart or Javascript then for the moment you can just ignore futures.

DCli works very hard to ensure that you don't need to worry about Futures.

This is very intentional.

If you stick to using DCli's built in functions then you can completely ignore Futures. If you start importing Dart's core libraries or third party libraries then you need to pay attention to return types.

The first time you try to call a method or function that returns a Future then you will know its time to come back here and read about Futures.

Until then, you can just skip this section.

How DCli manages futures

DCli does not stop you from using await, Futures, Isolates or any other Dart functionality. It's all yours to use and abuse as you will.

DClis global functions however intentionally avoid Futures.

The aim of DCli is to create a Bash-like simplicity to building CLI apps. Futures are great and all but they do make the code more complex and harder to read.

Futures also can make your scripts a little dangerous. If you copy a file and then want to append to the copied file, you had better be certain that the copy command has been completed before you start the append. DCli's global functions remove those complications.

If you are interested in how we avoid using Futures read up on waitFor and check out DCli's own waitForEx function that does stacktrace repair when an exception is thrown.

When you need to use futures you can read up on them in the Dart language Tour:

PreviousFunction ArgumentsNextstdin/stdout/stderr a primer

Last updated 1 year ago

Was this helpful?

https://dart.dev/guides/language/language-tour