Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
81746e98
Commit
81746e98
authored
Sep 11, 2015
by
Ian Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial sketch of install command and what devices look like.
parent
384ded5b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
4 deletions
+130
-4
sky_tools.dart
packages/flutter_tools/bin/sky_tools.dart
+16
-4
common.dart
packages/flutter_tools/lib/src/common.dart
+1
-0
device.dart
packages/flutter_tools/lib/src/device.dart
+67
-0
install.dart
packages/flutter_tools/lib/src/install.dart
+46
-0
No files found.
packages/flutter_tools/bin/sky_tools.dart
View file @
81746e98
...
@@ -7,6 +7,7 @@ import 'dart:io';
...
@@ -7,6 +7,7 @@ import 'dart:io';
import
'package:args/args.dart'
;
import
'package:args/args.dart'
;
import
'package:sky_tools/src/common.dart'
;
import
'package:sky_tools/src/common.dart'
;
import
'package:sky_tools/src/init.dart'
;
import
'package:sky_tools/src/init.dart'
;
import
'package:sky_tools/src/install.dart'
;
void
main
(
List
<
String
>
args
)
{
void
main
(
List
<
String
>
args
)
{
Map
<
String
,
CommandHandler
>
handlers
=
{};
Map
<
String
,
CommandHandler
>
handlers
=
{};
...
@@ -17,9 +18,13 @@ void main(List<String> args) {
...
@@ -17,9 +18,13 @@ void main(List<String> args) {
abbr:
'h'
,
negatable:
false
,
help:
'Display this help message.'
);
abbr:
'h'
,
negatable:
false
,
help:
'Display this help message.'
);
parser
.
addSeparator
(
'commands:'
);
parser
.
addSeparator
(
'commands:'
);
CommandHandler
handler
=
new
InitCommandHandler
();
for
(
CommandHandler
handler
in
[
new
InitCommandHandler
(),
new
InstallCommandHandler
()
])
{
parser
.
addCommand
(
handler
.
name
,
handler
.
parser
);
parser
.
addCommand
(
handler
.
name
,
handler
.
parser
);
handlers
[
handler
.
name
]
=
handler
;
handlers
[
handler
.
name
]
=
handler
;
}
ArgResults
results
;
ArgResults
results
;
...
@@ -33,7 +38,14 @@ void main(List<String> args) {
...
@@ -33,7 +38,14 @@ void main(List<String> args) {
if
(
results
[
'help'
])
{
if
(
results
[
'help'
])
{
_printUsage
(
parser
,
handlers
);
_printUsage
(
parser
,
handlers
);
}
else
if
(
results
.
command
!=
null
)
{
}
else
if
(
results
.
command
!=
null
)
{
handlers
[
results
.
command
.
name
].
processArgResults
(
results
.
command
);
handlers
[
results
.
command
.
name
]
.
processArgResults
(
results
.
command
)
.
then
((
int
code
)
=>
exit
(
code
))
.
catchError
((
e
,
stack
)
{
print
(
'Error running '
+
results
.
command
.
name
+
':
$e
'
);
print
(
stack
);
exit
(
2
);
});
}
else
{
}
else
{
_printUsage
(
parser
,
handlers
,
'No command specified.'
);
_printUsage
(
parser
,
handlers
,
'No command specified.'
);
exit
(
1
);
exit
(
1
);
...
...
packages/flutter_tools/lib/src/common.dart
View file @
81746e98
...
@@ -14,6 +14,7 @@ abstract class CommandHandler {
...
@@ -14,6 +14,7 @@ abstract class CommandHandler {
ArgParser
get
parser
;
ArgParser
get
parser
;
/// @return 0 for no errors or warnings executing command, 1 for warnings, 2 for errors.
Future
<
int
>
processArgResults
(
ArgResults
results
);
Future
<
int
>
processArgResults
(
ArgResults
results
);
void
printUsage
([
String
message
])
{
void
printUsage
([
String
message
])
{
...
...
packages/flutter_tools/lib/src/device.dart
0 → 100644
View file @
81746e98
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library
sky_tools
.
device
;
abstract
class
_Device
{
final
String
id
;
static
Map
<
String
,
_Device
>
_deviceCache
=
{};
factory
_Device
(
String
className
,
[
String
id
=
null
])
{
if
(
id
==
null
)
{
if
(
className
==
AndroidDevice
.
className
)
{
id
=
AndroidDevice
.
defaultDeviceID
;
}
else
{
throw
'Attempted to create a Device of unknown type
$className
'
;
}
}
return
_deviceCache
.
putIfAbsent
(
id
,
()
{
if
(
className
==
AndroidDevice
.
className
)
{
final
device
=
new
AndroidDevice
.
_
(
id
);
_deviceCache
[
id
]
=
device
;
return
device
;
}
else
{
throw
'Attempted to create a Device of unknown type
$className
'
;
}
});
}
_Device
.
_
(
this
.
id
);
/// Install an app package on the current device
bool
installApp
(
String
path
);
/// Check if the current device needs an installation
bool
needsInstall
();
/// Check if the device is currently connected
bool
isConnected
();
}
class
AndroidDevice
extends
_Device
{
static
const
String
className
=
'AndroidDevice'
;
static
final
String
defaultDeviceID
=
'default'
;
factory
AndroidDevice
([
String
id
=
null
])
{
return
new
_Device
(
className
,
id
);
}
AndroidDevice
.
_
(
id
)
:
super
.
_
(
id
);
@override
bool
installApp
(
String
path
)
{
return
false
;
}
@override
bool
needsInstall
()
{
return
true
;
}
@override
bool
isConnected
()
{
return
true
;
}
}
packages/flutter_tools/lib/src/install.dart
0 → 100644
View file @
81746e98
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library
sky_tools
.
install
;
import
'dart:async'
;
import
'package:args/args.dart'
;
import
'common.dart'
;
import
'device.dart'
;
class
InstallCommandHandler
extends
CommandHandler
{
InstallCommandHandler
()
:
super
(
'install'
,
'Install your Sky app on attached devices.'
);
@override
ArgParser
get
parser
{
ArgParser
parser
=
new
ArgParser
();
parser
.
addFlag
(
'help'
,
abbr:
'h'
,
negatable:
false
,
help:
'Display this help message.'
);
return
parser
;
}
@override
Future
<
int
>
processArgResults
(
ArgResults
results
)
async
{
if
(
results
[
'help'
])
{
printUsage
();
return
0
;
}
bool
installedSomewhere
=
false
;
AndroidDevice
android
=
new
AndroidDevice
();
if
(
android
.
isConnected
())
{
installedSomewhere
=
installedSomewhere
||
android
.
installApp
(
''
);
}
if
(
installedSomewhere
)
{
return
0
;
}
else
{
return
2
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment