parser method

Parser parser({
  1. bool runInShell = false,
})

parser runs the contents of this String as a cli command line reading all of the returned data and then passes the read lines to a Parser to be decoded as a specific file type.

EXPERIMENTAL: we may rework the data structures the parser returns.

DCli performs Glob expansion on command line arguments. See run for details.

If runInShell is true (defaults to false) then the command will be run in a shell. This may be required if you are trying to run a command that is builtin to the shell.

If the command returns a non-zero value an exception will be thrown.

 var json =
   'wget -qO- https://jsonplaceholder.typicode.com/todos/1'.parser.jsonDecode();

  print('Title: ${json["title"]}');

See forEach to capture output to stdout and stderr interactively toParagraph to concatenating the return lines into a single string. run to run the application without capturing its output start - to run the process fully detached. firstLine - returns just the first line written to stdout or stderr. lastLine - returns just the last line written to stdout or stderr. toList - returns a lines written to stdout and stderr as a list.

Implementation

Parser parser({bool runInShell = false}) {
  final lines = toList(runInShell: runInShell);

  return Parser(lines);
}