Ejemplo n.º 1
0
        private async Task <string> RunSingleImageBuild(DockerfileBuild imageBuild, string proxyNetworkId, IReadOnlyDictionary <string, string> buildMapping, IOutputObserver outputObserver, CancellationToken cancellationToken)
        {
            string id = imageBuild.FromCommand.Image;

            if (id == "scratch")
            {
                throw new Exception("FROM scratch is not supported");
            }

            var state = await InitialBuildState(id);

            foreach (var command in imageBuild.Commands)
            {
                var prevId = id;
                id = command switch {
                    RunExecCommand runExec => await HandleRunExecCommand(state, proxyNetworkId, runExec, outputObserver, cancellationToken),
                    RunShellCommand runShell => await HandleRunShellCommand(state, proxyNetworkId, runShell, outputObserver, cancellationToken),
                    _ => throw new Exception("Unexpected command"),
                };

                if (prevId != imageBuild.FromCommand.Image)
                {
                    await docker.Images.DeleteImageAsync(prevId, new ImageDeleteParameters(), cancellationToken);
                }

                state.Id = id;
            }

            return(id);
        }
Ejemplo n.º 2
0
        private Task <string> HandleRunShellCommand(BuildState state, string proxyNetworkId, RunShellCommand runShell, IOutputObserver outputObserver, CancellationToken cancellationToken)
        {
            var cmd = state.Shell.ToList();

            cmd.Add(runShell.ShellCommand);
            return(HandleRunCommandCommon(state, proxyNetworkId, runShell.BuildArgs, cmd, outputObserver, cancellationToken));
        }
Ejemplo n.º 3
0
    public Repl(string rawCommand, MainForm mainForm) :
        base(RemoveParameters(rawCommand), "REPL: " + GetShortName(rawCommand), SettingsMode.EditableNotFile)
    {
        tags           = BufferTag.NeedCorrectRemoving;
        onAdd          = OnAdd;
        onRemove       = OnRemove;
        additionKeyMap = new KeyMap();
        additionKeyMap.AddItem(new KeyItem(Keys.Enter, null,
                                           new KeyAction("&Edit\\REPL\\Enter command", OnEnter, null, false)));
        additionKeyMap.AddItem(new KeyItem(Keys.Back, null,
                                           new KeyAction("&Edit\\REPL\\Backspace", OnBackspace, null, false)));
        additionBeforeKeyMap = new KeyMap();
        additionBeforeKeyMap.AddItem(new KeyItem(Keys.Home, null,
                                                 new KeyAction("&Edit\\REPL\\Home", OnHome, null, false)));
        additionBeforeKeyMap.AddItem(new KeyItem(Keys.Shift | Keys.Home, null,
                                                 new KeyAction("&Edit\\REPL\\Home with selection", OnHomeWithSelection, null, false)));
        {
            KeyAction action = new KeyAction("&Edit\\REPL\\Prev command", DoMoveUp, null, false);
            additionKeyMap.AddItem(new KeyItem(Keys.Up, null, action));
            additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.P, null, action));
            additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.K, null, action));
        }
        {
            KeyAction action = new KeyAction("&Edit\\REPL\\Next command", DoMoveDown, null, false);
            additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.N, null, action));
            additionKeyMap.AddItem(new KeyItem(Keys.Down, null, action));
            additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.J, null, action));
        }
        {
            KeyAction action = new KeyAction("&Edit\\REPL\\Autocomplete path", DoAutocomplete, null, false);
            additionKeyMap.AddItem(new KeyItem(Keys.Control | Keys.Space, null, action));
            additionKeyMap.AddItem(new KeyItem(Keys.Tab, null, action));
        }

        string parameters = RunShellCommand.CutParametersFromLeft(ref rawCommand);
        int    index      = -1;

        for (int i = 0; i < rawCommand.Length; ++i)
        {
            if (rawCommand[i] == '"')
            {
                for (++i; i < rawCommand.Length; ++i)
                {
                    if (rawCommand[i] == '"')
                    {
                        break;
                    }
                }
            }
            else if (rawCommand[i] == ' ')
            {
                index = i;
                break;
            }
        }
        arguments = index != -1 ? rawCommand.Substring(index + 1) : "";
        command   = index != -1 ? rawCommand.Substring(0, index) : rawCommand;
        Encoding encoding = RunShellCommand.GetEncoding(mainForm, parameters);

        encodingPair = new EncodingPair(encoding, false);
        customSyntax = RunShellCommand.TryGetSyntax(parameters);
        string invitation = RunShellCommand.TryGetParameter(parameters, 'i');

        if (invitation == null)
        {
            invitation = "$";
        }
        if (invitation != "")
        {
            invitation += " ";
        }
        this.invitation          = invitation;
        Controller.onBeforePaint = OnBeforePaint;
    }