You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eznet-cli/main.cr

35 lines
831 B
Crystal

require "option_parser"
require "./ltnp/ltnp_operator"
OptionParser.parse do |parser|
parser.banner = "Welcome to eznetstat!"
parser.on "-v", "--version", "Show version" do
puts "0.1"
exit
end
parser.on "-h", "--help", "Show help" do
puts parser
exit
end
parser.on "-c PORT", "--check-port=PORT", "Get the process name and ID of process on port" do |port|
operator = LtnpOperator.new
puts operator.check_port port
exit
end
parser.on "-p PNAME", "--find-process=PNAME", "Find the port and ID of a process by name" do |p_name|
operator = LtnpOperator.new
puts operator.find_process p_name
exit
end
parser.on "-k PORT", "--kill-port=PORT", "Kill process on port" do |port|
operator = LtnpOperator.new
puts operator.kill_process_on_port port
exit
end
end