<commit_before>import Foundation

public class Servers {
    
    static var servers: [Server] = []
    
    public static func add(IP IP: String, user: String, roles: [Server.Role]) {
        servers.append(Server(IP: IP, user: user, roles: roles))
    }
}

public class Server {
    public enum Role {
        case App
        case DB
        case Web
    }
  
    public let IP: String
    public let user: String
    public let roles: [Role]
    
    private var commandStack: [String] = []
    
    public init(IP: String, user: String, roles: [Role]) {
        self.IP = IP
        self.user = user
        self.roles = roles
    }
    
    public func within(directory: String, block: () -> ()) {
        commandStack.append("cd \(directory)")
        block()
        commandStack.removeLast()
    }
    
    public func execute(command: String) {
        execute([command])
    }
    
    public func execute(commands: [String]) {
        // let config = NMSSHHostConfig()
        // config.hostname = IP
        // config.user = user
        // config.port = 22
        // config.identityFiles = [Config.SSHKey]
        // 
        // let session = NMSSHSession(host: IP, configs: [config], withDefaultPort: 8080, defaultUsername: user)
        // session.connect()
        // defer { session.disconnect() }
        
        let finalCommands = commandStack + commands
        let finalCommand = finalCommands.joinWithSeparator("; ")
        let call = "bash -c \"\(finalCommand)\""
        
        let task = NSTask()
        task.launchPath = "/usr/bin/ssh"
        task.arguments = ["-i \(Config.SSHKey)", "\(user)@\(IP)", "'\(call)"]
        
        print("On \(IP): \(call)")
        
        task.launch()
        task.waitUntilExit()
        
        // print("On \(IP): \(call)")
        // do {
        //     try session.channel.execute(call)
        // } catch let error as NSError {
        //     print(error)
        // }
    }
    
}

extension Config {
    public static var SSHKey: String = ""
}

extension NSTask {
    var commandCall: String {
        let launch = launchPath ?? ""
        let args = arguments?.joinWithSeparator(" ") ?? ""
        return "\(launch) \(args)"
    }
}<commit_msg>Trying ssh host<commit_after>import Foundation

public class Servers {
    
    static var servers: [Server] = []
    
    public static func add(IP IP: String, user: String, roles: [Server.Role], SSHHost: String) {
        servers.append(Server(IP: IP, user: user, roles: roles, SSHHost: SSHHost))
    }
}

public class Server {
    public enum Role {
        case App
        case DB
        case Web
    }
  
    public let IP: String
    public let user: String
    public let roles: [Role]
    public let SSHHost: String
    
    private var commandStack: [String] = []
    
    public init(IP: String, user: String, roles: [Role], SSHHost: String) {
        self.IP = IP
        self.user = user
        self.roles = roles
        self.SSHHost = SSHHost
    }
    
    public func within(directory: String, block: () -> ()) {
        commandStack.append("cd \(directory)")
        block()
        commandStack.removeLast()
    }
    
    public func execute(command: String) {
        execute([command])
    }
    
    public func execute(commands: [String]) {
        // let config = NMSSHHostConfig()
        // config.hostname = IP
        // config.user = user
        // config.port = 22
        // config.identityFiles = [Config.SSHKey]
        // 
        // let session = NMSSHSession(host: IP, configs: [config], withDefaultPort: 8080, defaultUsername: user)
        // session.connect()
        // defer { session.disconnect() }
        
        let finalCommands = commandStack + commands
        let finalCommand = finalCommands.joinWithSeparator("; ")
        let call = "bash -c \"\(finalCommand)\""
        
        let task = NSTask()
        task.launchPath = "/usr/bin/ssh"
        // task.arguments = ["-i \(Config.SSHKey)", "\(user)@\(IP)", "'\(call)"]
        task.arguments = ["\(SSHHost)", "'\(call)"]
        
        print("On \(IP): \(call)")
        
        task.launch()
        task.waitUntilExit()
        
        // print("On \(IP): \(call)")
        // do {
        //     try session.channel.execute(call)
        // } catch let error as NSError {
        //     print(error)
        // }
    }
    
}

extension Config {
    public static var SSHKey: String = ""
}

extension NSTask {
    var commandCall: String {
        let launch = launchPath ?? ""
        let args = arguments?.joinWithSeparator(" ") ?? ""
        return "\(launch) \(args)"
    }
}
{'fraction_non_alphanumeric': 0.13655053018827093, 'fraction_numerical': 0.002596840510711967, 'mean_word_length': 1.802910855063675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4512151', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1351, 'n_words': 353}