From a3228685d7b0c42464e563298a805e6a6a3fe4fb Mon Sep 17 00:00:00 2001 From: "Jakob L. Kreuze" Date: Fri, 26 Apr 2019 12:54:34 -0400 Subject: Add version and licensing information --- brisket.hy | 59 +++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 10 deletions(-) (limited to 'brisket.hy') diff --git a/brisket.hy b/brisket.hy index 0d4a1a6..f873029 100644 --- a/brisket.hy +++ b/brisket.hy @@ -1,3 +1,27 @@ +#!/usr/bin/env hy + +;; Copyright (C) 2019 Jakob L. Kreuze +;; +;; This program is free software: you can redistribute it and/or modify it under +;; the terms of the GNU General Public License as published by the Free Software +;; Foundation, either version 3 of the License, or (at your option) any later +;; version. +;; +;; This program is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +;; details. +;; +;; You should have received a copy of the GNU General Public License along with +;; this program. If not, see . + +"brisket.hy: Script for interacting with NNTP servers." + +(setv __author__ "Jakob L. Kreuze") +(setv __copyright__ "Copyright (C) 2019 Jakob L. Kreuze") +(setv __license__ "GPL") +(setv __version__ "0.1.0: Kansas City-style") + (import [configparser [ConfigParser]]) (import [os [getenv makedirs]]) (import [os.path [dirname expanduser]]) @@ -13,7 +37,8 @@ (setv *recognized-commands* ["describe-group" "help" "list-group" - "list-groups"]) + "list-groups" + "version"]) (defn help [&rest args] "Display the documentation for a command to stdout. @@ -31,6 +56,20 @@ usage: help [command]" (let [handler (get (globals) (.replace command "-" "_"))] (print (. handler __doc__))))) +(defn version [&rest args] + "Display the version of Brisket the user is currently running. + +usage: version" + (print (.format "brisket version {} + ________ +< Uhm... > + -------- + \ ^__^ + \ (oo)\\_______ + (__)\\ )\\/\\ + ||----w | + || ||" __version__))) + (defn list-groups [session &rest args] "List groups on the server, matching a pattern if one is given. @@ -124,16 +163,16 @@ The lookup order is: (err (.format "unrecognized command: {}" command)) (exit 1)) - ;; Special case for 'help', as it's the one command that doesn't require a + ;; Special case for 'help' and 'version', as the commands doesn't require a ;; connection to the NNTP server. - (if (= command "help") - (help #* (drop 2 argv)) - (let [user (get-username host) - password (get-password host)] - (with [session (NNTP_SSL host :user user :password password)] - ;; Otherwise, pull the function out of the global namespace. - (let [handler (get (globals) (.replace command "-" "_"))] - (handler session #* (drop 2 argv)))))))) + (cond [(= command "help") (help #* (drop 2 argv))] + [(= command "version") (version #* (drop 2 argv))] + [True (let [user (get-username host) + password (get-password host)] + (with [session (NNTP_SSL host :user user :password password)] + ;; Otherwise, pull the function out of the global namespace. + (let [handler (get (globals) (.replace command "-" "_"))] + (handler session #* (drop 2 argv)))))]))) ;; # To-be-converted Python ;; -- cgit v1.3