Skip to content

Commit

Permalink
New ASCII art on standalone startup
Browse files Browse the repository at this point in the history
  • Loading branch information
tomakehurst committed Jul 5, 2023
1 parent 357a1a4 commit 166c3b3
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ final DOCS_DIR = project(':').rootDir.getAbsolutePath() + '/docs-v2'
jar {
archiveBaseName.set('wiremock')
manifest {
attributes("Main-Class": "com.github.tomakehurst.wiremock.standalone.WireMockServerRunner")
attributes("Main-Class": "wiremock.Run")
attributes("Add-Exports": "java.base/sun.security.x509")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,45 @@
*/
package com.github.tomakehurst.wiremock.standalone;

import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.common.FatalStartupException;
import com.github.tomakehurst.wiremock.common.FileSource;
import com.github.tomakehurst.wiremock.http.ResponseDefinition;
import com.github.tomakehurst.wiremock.matching.RequestPattern;
import com.github.tomakehurst.wiremock.stubbing.StubMapping;

import java.io.PrintStream;

import static com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder.responseDefinition;
import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl;
import static com.github.tomakehurst.wiremock.core.WireMockApp.FILES_ROOT;
import static com.github.tomakehurst.wiremock.core.WireMockApp.MAPPINGS_ROOT;
import static com.github.tomakehurst.wiremock.http.RequestMethod.ANY;
import static com.github.tomakehurst.wiremock.matching.RequestPatternBuilder.newRequestPattern;
import static java.lang.System.err;
import static java.lang.System.out;

import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.common.FatalStartupException;
import com.github.tomakehurst.wiremock.common.FileSource;
import com.github.tomakehurst.wiremock.http.ResponseDefinition;
import com.github.tomakehurst.wiremock.matching.RequestPattern;
import com.github.tomakehurst.wiremock.stubbing.StubMapping;

public class WireMockServerRunner {

private static final String BANNER =
" /$$ /$$ /$$ /$$ /$$ /$$ \n"
+ "| $$ /$ | $$|__/ | $$$ /$$$ | $$ \n"
+ "| $$ /$$$| $$ /$$ /$$$$$$ /$$$$$$ | $$$$ /$$$$ /$$$$$$ /$$$$$$$| $$ /$$\n"
+ "| $$/$$ $$ $$| $$ /$$__ $$ /$$__ $$| $$ $$/$$ $$ /$$__ $$ /$$_____/| $$ /$$/\n"
+ "| $$$$_ $$$$| $$| $$ \\__/| $$$$$$$$| $$ $$$| $$| $$ \\ $$| $$ | $$$$$$/ \n"
+ "| $$$/ \\ $$$| $$| $$ | $$_____/| $$\\ $ | $$| $$ | $$| $$ | $$_ $$ \n"
+ "| $$/ \\ $$| $$| $$ | $$$$$$$| $$ \\/ | $$| $$$$$$/| $$$$$$$| $$ \\ $$\n"
+ "|__/ \\__/|__/|__/ \\_______/|__/ |__/ \\______/ \\_______/|__/ \\__/";
"\n"
+ "\u001B[34m██ ██ ██ ██████ ███████ \u001B[33m███ ███ ██████ ██████ ██ ██ \n"
+ "\u001B[34m██ ██ ██ ██ ██ ██ \u001B[33m████ ████ ██ ██ ██ ██ ██ \n"
+ "\u001B[34m██ █ ██ ██ ██████ █████ \u001B[33m██ ████ ██ ██ ██ ██ █████ \n"
+ "\u001B[34m██ ███ ██ ██ ██ ██ ██ \u001B[33m██ ██ ██ ██ ██ ██ ██ ██ \n"
+ "\u001B[34m ███ ███ ██ ██ ██ ███████ \u001B[33m██ ██ ██████ ██████ ██ ██ \n"
+ "\n\u001B[0m"
+ "----------------------------------------------------------------\n"
+ "| Cloud: https://wiremock.io/cloud |\n"
+ "| |\n"
+ "| Slack: https://slack.wiremock.org |\n"
+ "----------------------------------------------------------------";

private WireMockServer wireMockServer;

public void run(String... args) {
suppressSlf4jWarnings();

CommandLineOptions options = new CommandLineOptions(args);
if (options.help()) {
out.println(options.helpText());
Expand Down Expand Up @@ -94,6 +103,31 @@ public void run(String... args) {
}
}

private static void suppressSlf4jWarnings() {
System.setErr(new PrintStream(err) {
@Override
public void println(String s) {
if (!s.startsWith("SLF4J")) {
super.println(s);
}
}

@Override
public void println(char[] chars) {
if (!new String(chars).startsWith("SLF4J")) {
super.println(chars);
}
}

@Override
public void println(Object o) {
if (!o.toString().startsWith("SLF4J")) {
super.println(o);
}
}
});
}

private void addProxyMapping(final String baseUrl) {
wireMockServer.loadMappingsUsing(
stubMappings -> {
Expand Down Expand Up @@ -124,8 +158,4 @@ public boolean isRunning() {
public int port() {
return wireMockServer.port();
}

public static void main(String... args) {
new WireMockServerRunner().run(args);
}
}
25 changes: 25 additions & 0 deletions src/main/java/wiremock/Run.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2023 Thomas Akehurst
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package wiremock;

This comment has been minimized.

Copy link
@oleg-nenashev

oleg-nenashev Jul 29, 2023

Member

Should it be org.wiremock to align with GroupID?


import com.github.tomakehurst.wiremock.standalone.WireMockServerRunner;

public class Run extends WireMockServerRunner {

public static void main(String... args) {
new Run().run(args);
}
}

0 comments on commit 166c3b3

Please sign in to comment.