Skip to content

Commit 2cf24bb

Browse files
committed
Initial commit.
0 parents  commit 2cf24bb

File tree

10 files changed

+162
-0
lines changed

10 files changed

+162
-0
lines changed

pkgs/cli_util/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.buildlog
2+
.DS_Store
3+
.idea
4+
.pub/
5+
.project
6+
.settings
7+
build/
8+
packages
9+
pubspec.lock

pkgs/cli_util/.status

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2+
# for details. All rights reserved. Use of this source code is governed by a
3+
# BSD-style license that can be found in the LICENSE file.

pkgs/cli_util/AUTHORS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the cli_util project. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Google Inc.

pkgs/cli_util/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 0.0.1
4+
5+
- Initial version

pkgs/cli_util/CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Want to contribute? Great! First, read this page (including the small print at
2+
the end).
3+
4+
### Before you contribute
5+
Before we can use your code, you must sign the
6+
[Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual)
7+
(CLA), which you can do online. The CLA is necessary mainly because you own the
8+
copyright to your changes, even after your contribution becomes part of our
9+
codebase, so we need your permission to use and distribute your code. We also
10+
need to be sure of various other things—for instance that you'll tell us if you
11+
know that your code infringes on other people's patents. You don't have to sign
12+
the CLA until after you've submitted your code for review and a member has
13+
approved it, but you must do it before we can put your code into our codebase.
14+
15+
Before you start working on a larger contribution, you should get in touch with
16+
us first through the issue tracker with your idea so that we can help out and
17+
possibly guide you. Coordinating up front makes it much easier to avoid
18+
frustration later on.
19+
20+
### Code reviews
21+
All submissions, including submissions by project members, require review.
22+
23+
### File headers
24+
All files in the project must start with the following header.
25+
26+
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
27+
// for details. All rights reserved. Use of this source code is governed by a
28+
// BSD-style license that can be found in the LICENSE file.
29+
30+
### The small print
31+
Contributions made by corporations are covered by a different agreement than the
32+
one above, the
33+
[Software Grant and Corporate Contributor License Agreement](https://developers.google.com/open-source/cla/corporate).

pkgs/cli_util/LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright 2015, the Dart project authors. All rights reserved.
2+
Redistribution and use in source and binary forms, with or without
3+
modification, are permitted provided that the following conditions are
4+
met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pkgs/cli_util/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# cli_util
2+
3+
A micro framework for building commandline apps.
4+
5+
## Features and bugs
6+
7+
Please file feature requests and bugs at the [issue tracker][tracker].
8+
9+
[tracker]: https://github.com/dart-lang/cli_util/issues

pkgs/cli_util/codereview.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CODE_REVIEW_SERVER: https://chromiumcodereview.appspot.com/
2+
VIEW_VC: https://github.com/dart-lang/cli_util/commit/
3+

pkgs/cli_util/lib/cli_util.dart

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
library cli_util;
6+
7+
import 'dart:io';
8+
9+
import 'package:which/which.dart';
10+
11+
/// Return the path to the current Dart SDK. This will return `null` if we are
12+
/// unable to locate the Dart SDK.
13+
Directory getSdkDir([List<String> cliArgs]) {
14+
// Look for --dart-sdk on the command line.
15+
if (cliArgs != null) {
16+
int index = cliArgs.indexOf('--dart-sdk');
17+
18+
if (index != -1 && (index + 1 < cliArgs.length)) {
19+
return new Directory(cliArgs[index + 1]);
20+
}
21+
22+
for (String arg in cliArgs) {
23+
if (arg.startsWith('--dart-sdk=')) {
24+
return new Directory(arg.substring('--dart-sdk='.length));
25+
}
26+
}
27+
}
28+
29+
// Look in env['DART_SDK']
30+
if (Platform.environment['DART_SDK'] != null) {
31+
return new Directory(Platform.environment['DART_SDK']);
32+
}
33+
34+
// Look relative to the dart executable.
35+
Directory sdkDirectory = new File(Platform.executable).parent.parent;
36+
if (_isSdkDir(sdkDirectory)) return sdkDirectory;
37+
38+
// Try and locate the VM using 'which'.
39+
String executable = whichSync('dart', orElse: () => null);
40+
41+
// In case Dart is symlinked (e.g. homebrew on Mac) follow symbolic links.
42+
Link link = new Link(executable);
43+
if (link.existsSync()) {
44+
executable = link.resolveSymbolicLinksSync();
45+
}
46+
47+
File dartVm = new File(executable);
48+
Directory dir = dartVm.parent.parent;
49+
if (_isSdkDir(dir)) return dir;
50+
51+
return null;
52+
}
53+
54+
bool _isSdkDir(Directory dir) => _joinFile(dir, ['version']).existsSync();
55+
56+
File _joinFile(Directory dir, List<String> files) {
57+
String pathFragment = files.join(Platform.pathSeparator);
58+
return new File("${dir.path}${Platform.pathSeparator}${pathFragment}");
59+
}

pkgs/cli_util/pubspec.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: cli_util
2+
version: 0.0.1
3+
author: Dart Team <[email protected]>
4+
description: A micro framework for building commandline apps.
5+
homepage: https://github.com/dart-lang/cli_util
6+
environment:
7+
sdk: '>=1.0.0 <2.0.0'
8+
dependencies:
9+
which: '>=0.1.2 <0.2.0'

0 commit comments

Comments
 (0)