Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: pkg/fletchc/lib/src/verbs/actions.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/fletchc/lib/src/verbs/README.md ('k') | pkg/fletchc/lib/src/verbs/attach_verb.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dartino 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.md file.
4
5 library fletchc.verbs.verbs;
6
7 import 'infrastructure.dart' show
8 AnalyzedSentence,
9 Future,
10 TargetKind,
11 VerbContext;
12
13 import 'attach_verb.dart' show
14 attachAction;
15
16 import 'compile_verb.dart' show
17 compileAction;
18
19 import 'create_verb.dart' show
20 createAction;
21
22 import 'debug_verb.dart' show
23 debugAction;
24
25 import 'export_verb.dart' show
26 exportAction;
27
28 import 'help_verb.dart' show
29 helpAction;
30
31 import 'run_verb.dart' show
32 runAction;
33
34 import 'x_end_verb.dart' show
35 endAction;
36
37 import 'x_servicec_verb.dart' show
38 servicecAction;
39
40 import 'x_upgrade_verb.dart' show
41 upgradeAction;
42
43 import 'x_download_tools_verb.dart' show
44 downloadToolsAction;
45
46 import 'quit_verb.dart' show
47 quitAction;
48
49 import 'show_verb.dart' show
50 showAction;
51
52 typedef Future<int> DoAction(AnalyzedSentence sentence, VerbContext context);
53
54 class Action {
55 final DoAction perform;
56
57 final String documentation;
58
59 /// True if this verb needs "in session NAME".
60 final bool requiresSession;
61
62 /// True if this verb needs "to file NAME".
63 // TODO(ahe): Should be "to uri NAME".
64 final bool requiresToUri;
65
66 /// True if this verb requires a session target (that is, "session NAME"
67 /// without "in").
68 final bool requiresTargetSession;
69
70 /// True if this verb allows trailing arguments.
71 final bool allowsTrailing;
72
73 /// Optional kind of target required by this verb.
74 final TargetKind requiredTarget;
75
76 /// Indicates whether the action needs a target. If [requiredTarget] is
77 /// non-null, this flag is set to `true`, regardless of the value given
78 /// in the constructor.
79 final bool requiresTarget;
80
81 /// Optional list of targets supported (but not required) by this verb.
82 final List<TargetKind> supportedTargets;
83
84 /// True if this verb supports "with <URI>"
85 final bool supportsWithUri;
86
87 const Action(
88 this.perform,
89 this.documentation,
90 {this.requiresSession: false,
91 this.requiresToUri: false,
92 this.allowsTrailing: false,
93 bool requiresTargetSession: false,
94 TargetKind requiredTarget,
95 bool requiresTarget: false,
96 this.supportedTargets,
97 this.supportsWithUri: false})
98 : this.requiresTargetSession = requiresTargetSession,
99 this.requiredTarget =
100 requiresTargetSession ? TargetKind.SESSION : requiredTarget,
101 requiresTarget = !identical(requiredTarget, null) ||
102 requiresTarget ||
103 requiresTargetSession;
104 }
105
106
107 // TODO(ahe): Support short and long documentation.
108
109 /// Common actions are displayed in the default help screen.
110 ///
111 /// Please make sure their combined documentation fit in in 80 columns by 20
112 /// lines. The default terminal size is normally 80x24. Two lines are used
113 /// for the prompts before and after running fletch. Another two lines may be
114 /// used to print an error message.
115 const Map<String, Action> commonActions = const <String, Action>{
116 "help": helpAction,
117 "run": runAction,
118 "show": showAction,
119 "quit": quitAction,
120 };
121
122 /// Uncommon verbs aren't displayed in the normal help screen.
123 ///
124 /// These verbs are displayed when running `fletch help all`.
125 const Map<String, Action> uncommonActions = const <String, Action>{
126 "attach": attachAction,
127 "compile": compileAction,
128 "create": createAction,
129 "debug": debugAction,
130 "export": exportAction,
131 "x-download-tools": downloadToolsAction,
132 "x-end": endAction,
133 "x-servicec": servicecAction,
134 "x-upgrade": upgradeAction,
135 };
OLDNEW
« no previous file with comments | « pkg/fletchc/lib/src/verbs/README.md ('k') | pkg/fletchc/lib/src/verbs/attach_verb.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698