@@ -57,86 +57,116 @@ public RuntimeCommand() : base("runtime", "Installs the runtime on the robot")
57
57
58
58
public async Task < int > HandleCommand ( int team , string ? project , bool download , bool install , string ? location )
59
59
{
60
- ;
60
+ var msBuild = ResolveProject ( project ) ;
61
+ if ( msBuild == null )
62
+ {
63
+
64
+ return - 1 ;
65
+ }
66
+ var builder = new ContainerBuilder ( ) ;
67
+ AutoFacUtilites . AddCommonServicesToContainer ( builder , msBuild , team , false ,
68
+ false ) ;
69
+ var container = builder . Build ( ) ;
70
+
71
+ using ( var scope = container . BeginLifetimeScope ( ) )
72
+ {
73
+ var runtimeProvider = scope . Resolve < IRuntimeProvider > ( ) ;
74
+ if ( download )
75
+ {
76
+ await runtimeProvider . DownladRuntimeAsync ( ) ;
77
+ }
78
+
79
+ if ( install )
80
+ {
81
+ if ( location != null )
82
+ {
83
+ await runtimeProvider . InstallRuntimeAsync ( location ) ;
84
+ }
85
+ else
86
+ {
87
+ await runtimeProvider . InstallRuntimeAsync ( ) ;
88
+ }
89
+ }
90
+ }
91
+
61
92
return 0 ;
62
- ;
63
93
}
64
94
65
- // private CommandOption _downloadOption;
66
- // private CommandOption _installOption;
67
- // private CommandOption _locationOption;
68
- //#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
69
-
70
- // public static DotNetSubCommandBase Create()
71
- // {
72
- // var command = new RuntimeCommand
73
- // {
74
- // Name = "runtime",
75
- // Description = "Installs the runtime on the robot",
76
- // HandleRemainingArguments = false
77
- // };
78
-
79
- // SetupBaseOptions(command);
80
-
81
- // command._downloadOption = command.Option(
82
- // "-d|--download",
83
- // "Download the runtime",
84
- // CommandOptionType.NoValue
85
- // );
86
-
87
- // command._installOption = command.Option(
88
- // "-i|--install",
89
- // "Install the runtime",
90
- // CommandOptionType.NoValue
91
- // );
92
-
93
- // command._locationOption = command.Option(
94
- // "-l|--location",
95
- // "Local runtime location",
96
- // CommandOptionType.SingleValue
97
- // );
98
-
99
- // return command;
100
- // }
101
-
102
- //public override async Task<int> RunAsync(string fileOrDirectory)
103
- //{
104
- // var builder = new ContainerBuilder();
105
- // AutoFacUtilites.AddCommonServicesToContainer(builder, fileOrDirectory, this,
106
- // false);
107
- // builder.RegisterType<MonoRuntimeProvider>().As<IRuntimeProvider>();
108
- // var container = builder.Build();
109
-
110
- // using (var scope = container.BeginLifetimeScope())
111
- // {
112
- // if (!_downloadOption.HasValue() && !_installOption.HasValue())
113
- // {
114
- // throw scope.Resolve<IExceptionThrowerProvider>().ThrowException(
115
- // "No argument specified. Must provide an argument to use"
116
- // );
117
- // }
118
-
119
- // var runtimeProvider = scope.Resolve<IRuntimeProvider>();
120
- // if (_downloadOption.HasValue())
121
- // {
122
- // await runtimeProvider.DownladRuntimeAsync();
123
- // }
124
-
125
- // if (_installOption.HasValue())
126
- // {
127
- // if (_locationOption.HasValue())
128
- // {
129
- // await runtimeProvider.InstallRuntimeAsync(_locationOption.Value());
130
- // }
131
- // else
132
- // {
133
- // await runtimeProvider.InstallRuntimeAsync();
134
- // }
135
- // }
136
- // }
137
-
138
- // return 0;
139
- //}
140
-
95
+ // private CommandOption _downloadOption;
96
+ // private CommandOption _installOption;
97
+ // private CommandOption _locationOption;
98
+ //#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
99
+
100
+ // public static DotNetSubCommandBase Create()
101
+ // {
102
+ // var command = new RuntimeCommand
103
+ // {
104
+ // Name = "runtime",
105
+ // Description = "Installs the runtime on the robot",
106
+ // HandleRemainingArguments = false
107
+ // };
108
+
109
+ // SetupBaseOptions(command);
110
+
111
+ // command._downloadOption = command.Option(
112
+ // "-d|--download",
113
+ // "Download the runtime",
114
+ // CommandOptionType.NoValue
115
+ // );
116
+
117
+ // command._installOption = command.Option(
118
+ // "-i|--install",
119
+ // "Install the runtime",
120
+ // CommandOptionType.NoValue
121
+ // );
122
+
123
+ // command._locationOption = command.Option(
124
+ // "-l|--location",
125
+ // "Local runtime location",
126
+ // CommandOptionType.SingleValue
127
+ // );
128
+
129
+ // return command;
130
+ // }
131
+
132
+ //public override async Task<int> RunAsync(string fileOrDirectory)
133
+ //{
134
+ // var builder = new ContainerBuilder();
135
+ // AutoFacUtilites.AddCommonServicesToContainer(builder, fileOrDirectory, this,
136
+ // false);
137
+ // builder.RegisterType<MonoRuntimeProvider>().As<IRuntimeProvider>();
138
+ // var container = builder.Build();
139
+
140
+ // using (var scope = container.BeginLifetimeScope())
141
+ // {
142
+ // if (!_downloadOption.HasValue() && !_installOption.HasValue())
143
+ // {
144
+ // throw scope.Resolve<IExceptionThrowerProvider>().ThrowException(
145
+ // "No argument specified. Must provide an argument to use"
146
+ // );
147
+ // }
148
+
149
+ // var runtimeProvider = scope.Resolve<IRuntimeProvider>();
150
+ // if (_downloadOption.HasValue())
151
+ // {
152
+ // await runtimeProvider.DownladRuntimeAsync();
153
+ // }
154
+
155
+ // if (_installOption.HasValue())
156
+ // {
157
+ // if (_locationOption.HasValue())
158
+ // {
159
+ // await runtimeProvider.InstallRuntimeAsync(_locationOption.Value());
160
+ // }
161
+ // else
162
+ // {
163
+ // await runtimeProvider.InstallRuntimeAsync();
164
+ // }
165
+ // }
166
+ // }
167
+
168
+ // return 0;
169
+ //}
170
+
141
171
}
142
172
}
0 commit comments