// Path: src/main/java/com/optimaize/command4j/cache/ExecutorCache.java
// public final class ExecutorCache {
// 
//     private final Cache<ExecutorCacheKey, Object> cache;
// 
//     /**
//      * Creates a cache with the given Guava cache.
//      */
//     public ExecutorCache(@NotNull Cache<ExecutorCacheKey, Object> cache) {
//         this.cache = cache;
//     }
// 
//     /**
//      * Creates a cache with a default Guava cache that works for most scenarios.
//      */
//     public ExecutorCache() {
//         this.cache = CacheBuilder
//                 .newBuilder()
//                 .softValues() //disputable.
//                 .maximumSize(500)
//                 .build();
//     }
// 
//     @Nullable
//     public <V> V getIfPresent(@NotNull ExecutorCacheKey<V> key) {
//         //noinspection unchecked
//         return (V) cache.getIfPresent(key);
//     }
// 
//     public <V> V get(@NotNull ExecutorCacheKey<V> key, @NotNull Callable<? extends V> valueLoader) throws Exception {
//         //to understand this, see what cache.get() throws. we want to unwrap the throwable, whatever it was.
//         try {
//             //noinspection unchecked
//             return (V) cache.get(key, valueLoader);
//         } catch (UncheckedExecutionException | ExecutionError e) {
//             throw Throwables.propagate(e.getCause());
//         } catch (ExecutionException e) {
//             Throwables.propagateIfInstanceOf(e.getCause(), Exception.class);
//             throw Throwables.propagate(e.getCause());
//         }
//     }
// 
//     public <V> void put(@NotNull ExecutorCacheKey<V> key, V value) {
//         cache.put(key, value);
//     }
// 
//     public void invalidate(@NotNull ExecutorCacheKey<?> key) {
//         cache.invalidate(key);
//     }
// 
//     public long size() {
//         return cache.size();
//     }
// 
//     public void invalidateAll() {
//         cache.invalidateAll();
//     }
// 
//     public ImmutableMap<ExecutorCacheKey, Object> getAllPresent(@NotNull Iterable<?> keys) {
//         return cache.getAllPresent(keys);
//     }
// }


import com.optimaize.command4j.*;
import com.optimaize.command4j.cache.ExecutorCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import org.jetbrains.annotations.NotNull;
package com.optimaize.command4j.impl;


/**
 * Runs a setup command.
 *
 * @author Eike Kettner
 * @author Fabian Kessler
 */
class Runner {
    private static final Logger log = LoggerFactory.getLogger(Runner.class);
    private final CommandExecutor executor;
// Path: src/main/java/com/optimaize/command4j/cache/ExecutorCache.java
// public final class ExecutorCache {
// 
//     private final Cache<ExecutorCacheKey, Object> cache;
// 
//     /**
//      * Creates a cache with the given Guava cache.
//      */
//     public ExecutorCache(@NotNull Cache<ExecutorCacheKey, Object> cache) {
//         this.cache = cache;
//     }
// 
//     /**
//      * Creates a cache with a default Guava cache that works for most scenarios.
//      */
//     public ExecutorCache() {
//         this.cache = CacheBuilder
//                 .newBuilder()
//                 .softValues() //disputable.
//                 .maximumSize(500)
//                 .build();
//     }
// 
//     @Nullable
//     public <V> V getIfPresent(@NotNull ExecutorCacheKey<V> key) {
//         //noinspection unchecked
//         return (V) cache.getIfPresent(key);
//     }
// 
//     public <V> V get(@NotNull ExecutorCacheKey<V> key, @NotNull Callable<? extends V> valueLoader) throws Exception {
//         //to understand this, see what cache.get() throws. we want to unwrap the throwable, whatever it was.
//         try {
//             //noinspection unchecked
//             return (V) cache.get(key, valueLoader);
//         } catch (UncheckedExecutionException | ExecutionError e) {
//             throw Throwables.propagate(e.getCause());
//         } catch (ExecutionException e) {
//             Throwables.propagateIfInstanceOf(e.getCause(), Exception.class);
//             throw Throwables.propagate(e.getCause());
//         }
//     }
// 
//     public <V> void put(@NotNull ExecutorCacheKey<V> key, V value) {
//         cache.put(key, value);
//     }
// 
//     public void invalidate(@NotNull ExecutorCacheKey<?> key) {
//         cache.invalidate(key);
//     }
// 
//     public long size() {
//         return cache.size();
//     }
// 
//     public void invalidateAll() {
//         cache.invalidateAll();
//     }
// 
//     public ImmutableMap<ExecutorCacheKey, Object> getAllPresent(@NotNull Iterable<?> keys) {
//         return cache.getAllPresent(keys);
//     }
// }


// Path: src/main/java/com/optimaize/command4j/impl/Runner.java
import com.optimaize.command4j.*;
import com.optimaize.command4j.cache.ExecutorCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import org.jetbrains.annotations.NotNull;

package com.optimaize.command4j.impl;


/**
 * Runs a setup command.
 *
 * @author Eike Kettner
 * @author Fabian Kessler
 */
class Runner {
    private static final Logger log = LoggerFactory.getLogger(Runner.class);
    private final CommandExecutor executor;
    private final ExecutorCache cache;