Class: Lipaste::CLI
- Inherits:
-
Thor
- Object
- Thor
- Lipaste::CLI
- Defined in:
- lib/lipaste/cli.rb
Instance Method Summary collapse
Instance Method Details
#login ⇒ Object
43 44 45 |
# File 'lib/lipaste/cli.rb', line 43 def login Lipaste::Config.create_config end |
#logout ⇒ Object
48 49 50 |
# File 'lib/lipaste/cli.rb', line 48 def logout Lipaste::Config.destroy end |
#upload ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lipaste/cli.rb', line 15 def upload conf = Lipaste::Config.read unless conf == nil begin = Lipaste::Lichess.login conf[:username], conf[:password] rescue STDERR.puts "Error logging in to Lichess" exit 1 end end if .pgn == nil # Use a file from ~/Downloads by default pgn = File.read Lipaste::Files.get_latest_downloaded_pgn elsif File.exists? .pgn # Read the file if a path is provided pgn = File.read .pgn else # Treat any other argument as a PGN string STDERR.puts "Invalid PGN file: #{options.pgn}" exit 1 end puts Lipaste::Lichess.upload , pgn end |
#version ⇒ Object
54 55 56 |
# File 'lib/lipaste/cli.rb', line 54 def version say Lipaste::VERSION end |