-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[fuchsia_ctl] initial emulator support #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cc6bb8d
Initial emu tooling
546ea4a
emu tool
47e2ade
review myself
e13302d
lint
822798b
CommandLine utility and review comments
eb51c98
public key
c539669
use public key
6d3f76f
plugin lint fixes
9e3eab6
apparently that lint doesn't work on ci
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,9 @@ | |
| import 'dart:io'; | ||
|
|
||
| import 'package:meta/meta.dart'; | ||
| import 'package:fuchsia_ctl/fuchsia_ctl.dart'; | ||
| import 'package:fuchsia_ctl/src/ssh_client.dart'; | ||
| import 'package:uuid/uuid.dart'; | ||
|
|
||
| import 'operation_result.dart'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't needed anymore?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was clean up as it was already imported from the high level fuchsia_ctl since this imports the ssh class. |
||
| import 'package:fuchsia_ctl/fuchsia_ctl.dart'; | ||
|
|
||
| const SshClient _kSsh = SshClient(); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Copyright 2020 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:io'; | ||
|
|
||
| import 'package:meta/meta.dart'; | ||
| import 'package:process/process.dart'; | ||
|
|
||
| /// Class for common actions with processes on the command line. | ||
| @immutable | ||
| class CommandLine { | ||
| /// Create a new instance of [CommandLine]. | ||
| const CommandLine( | ||
| {this.processManager = const LocalProcessManager(), | ||
| @visibleForTesting this.stdoutValue, | ||
| @visibleForTesting this.stderrValue}); | ||
|
|
||
| /// The underlying [ProcessManager] to use for running on the current shell. | ||
| final ProcessManager processManager; | ||
|
|
||
| /// Mock value for use in tests. | ||
| final Stdout stdoutValue; | ||
|
|
||
| /// Mock value for use in tests. | ||
| final Stdout stderrValue; | ||
|
|
||
| /// Current shells stdout to use. | ||
| Stdout get shellStdout => stdoutValue ?? stdout; | ||
|
|
||
| /// Current shells stderr to use. | ||
| Stdout get shellStderr => stderrValue ?? stderr; | ||
|
|
||
| /// Run [command] and handle its stdio. Once [command] is complete, it will | ||
| /// output its stdio to the console. | ||
| /// | ||
| /// Use this for tasks where stdio does not need to be monitored. | ||
| /// | ||
| /// Throw [CommandLineException] if [command] returns a non-0 exit code. | ||
| Future<void> run(List<String> command) async { | ||
| shellStdout.writeln(command.join(' ')); | ||
| final ProcessResult process = await processManager.run(command); | ||
| shellStdout.writeln(process.stdout); | ||
| shellStderr.writeln(process.stderr); | ||
|
|
||
| if (process.exitCode != 0) { | ||
| throw CommandLineException('${command.first} did not return exit code 0'); | ||
| } | ||
| } | ||
|
|
||
| /// Start [command] and handle its stdio by streaming it to the existing | ||
| /// stdio. While [command] is running, its stdio is streamed to the shell. | ||
| /// | ||
| /// Use this for long running tasks where stdio should be monitored. | ||
| /// | ||
| /// Throw [CommandLineException] if [command] returns a non-0 exit code. | ||
| Future<Process> start(List<String> command) async { | ||
| shellStdout.writeln(command.join(' ')); | ||
| final Process process = await processManager.start(command); | ||
| shellStdout.addStream(process.stdout); | ||
| shellStderr.addStream(process.stderr); | ||
|
|
||
| if (await process.exitCode != 0) { | ||
| throw CommandLineException('${command.first} did not return exit code 0'); | ||
| } | ||
|
|
||
| return process; | ||
| } | ||
| } | ||
|
|
||
| /// Wraps exceptions thrown by [CommandLine]. | ||
| class CommandLineException implements Exception { | ||
| /// Creates a new [CommandLineException]. | ||
| const CommandLineException(this.message); | ||
|
|
||
| /// The user-facing message to display. | ||
| final String message; | ||
|
|
||
| @override | ||
| String toString() => message; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a blocking command? e.g it will remain running until calling ctrl+c?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's blocking. Should that be documented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in the code. I couldn't find a way to configure it to show with ArgParser