G4t 2.0 → 2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/g4tOptions.rb +128 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3444e27ffa161b5177255951d95af8d36a6ab092e16999750f658e28c31004d6
4
- data.tar.gz: e346503def345173e3a349eb4f68e935e286be17ce575d9b91c0f4770fc4d8e0
3
+ metadata.gz: d0b0c6e035ee40cae7b4532fa160ef0f1421e629751a9aab0396d9cf92e5ee85
4
+ data.tar.gz: dbbd7db3dffa34beff19ba8b425620f0aab00a04c63557d2c374603fe1bb7f9d
5
5
  SHA512:
6
- metadata.gz: dc57f81f30d916d78d865ad02ccb8b394d8c273ce6e8fce5f5ba4981e51d80a94567c24f50b9f208cb00d740a4cfcf5a9033f64e7ba4df778571fa3a67c8503a
7
- data.tar.gz: e0507409baafae6d26821b61528501c428b433940ecca33ce92f796bc14d160cd42a479aff3fc685cd73d0d7b6c76a6d3b39d732e7ad1877f067adfbbee13899
6
+ metadata.gz: 41a4ceafc114d56c036ff62e87fa288fcf8ed6b1cd4c1e0fd0a36b42570b110ddebfd65bef69b9ad2979bcba144033fb6465c319fddabff49bc9d76ee48299ed
7
+ data.tar.gz: de8c478377312f8d672b9eb5edeb37707d4f9fc79cae99044ac8606f98fb81183c71a8ac4d58835fdcc0202a5b3e1601c7d265103547a4be0af575da9627d798
@@ -0,0 +1,128 @@
1
+ class Options
2
+ def initialize
3
+ @prompt = TTY::Prompt.new
4
+ end
5
+
6
+ def commit_files
7
+ $lastmsg = "Now that we commited the files"
8
+ msg = @prompt.ask("Commit message:")
9
+
10
+ if msg[0] != "\""
11
+ msg = "\"#{msg}"
12
+ end
13
+
14
+ if msg[-1] != "\""
15
+ msg = "#{msg}\""
16
+ end
17
+
18
+ puts msg
19
+ run_command("git commit -m #{msg}")
20
+ end
21
+
22
+ def add_files
23
+ $lastmsg = "Now that we added the files"
24
+ all_files = @prompt.yes?("Add all files?")
25
+ if all_files
26
+ cmd = "git add ."
27
+ puts("Adding all files...")
28
+ else
29
+ fname = @prompt.ask("File to add:")
30
+ cmd = "git add #{fname}"
31
+ end
32
+ run_command(cmd)
33
+ end
34
+
35
+ def logs
36
+ run_command("git log")
37
+ end
38
+
39
+ def push_branch
40
+ branch = @prompt.ask("Branch to push:")
41
+ run_command("git push origin #{branch}")
42
+ end
43
+
44
+ def remote_adress
45
+ $lastmsg = "Now that we the remote address"
46
+ uname = @prompt.ask("Your github username:")
47
+ repo = @prompt.ask("Your repository name:")
48
+ puts("Adding remote repository https://github.com/#{uname}/#{repo}...")
49
+ run_command("git remote add origin https://github.com/#{uname}/#{repo}.git")
50
+ end
51
+
52
+ def status
53
+ run_command("git status")
54
+ end
55
+
56
+ def clone_repo
57
+ uname = @prompt.ask("Username:")
58
+ repo = @prompt.ask("Repository name:")
59
+ run_command("git clone https://github.com/#{uname}/#{repo}/")
60
+ end
61
+
62
+ def restore
63
+ fname = @prompt.ask("File name:")
64
+ run_command("git restore #{fname}")
65
+ end
66
+
67
+ def reset
68
+ commit = @prompt.ask("Commit id:")
69
+ run_command("git reset --hard #{commit}")
70
+ end
71
+
72
+ def hard_reset
73
+ confirmation = @prompt.yes?("do you really want to hard reset?")
74
+
75
+ if confirmation
76
+ run_command("git reset --hard HEAD~")
77
+ else
78
+ puts "Cancelling operation"
79
+ end
80
+
81
+ end
82
+
83
+ def initialize_git
84
+ $lastmsg = "Now that we initialized .git"
85
+ puts("Initializing Git repository in '#{Dir.pwd}/.git'...")
86
+ run_command("git init")
87
+ end
88
+
89
+ def diff
90
+ run_command("git diff")
91
+ end
92
+
93
+ def change_branch
94
+ bname = @prompt.ask("Branch name:")
95
+ run_command("git checkout -b #{bname}")
96
+ end
97
+
98
+ def git_info
99
+ status = {
100
+ "Git branch" => IO.popen("git branch"),
101
+ "Repository url" => IO.popen("git config --get remote.origin.url")
102
+ }
103
+ status.each do |k, v|
104
+ puts("#{k}: #{v.read}")
105
+ end
106
+ puts("____________\n\n")
107
+ end
108
+
109
+ def remove_file
110
+ file_name = @prompt.ask("Enter the file name: ")
111
+ run_command("git rm #{file_name}")
112
+ end
113
+
114
+ def show_last_commit
115
+ run_command("git show")
116
+ end
117
+
118
+ def pull_changes
119
+ git_pull_options = ["rebase", "no-rebase", "ff-only"]
120
+ chose = @prompt.select("chose: ", git_pull_options)
121
+ run_command("git pull --#{chose}")
122
+ end
123
+
124
+ def run_command(cmd)
125
+ puts "Command: #{cmd}"
126
+ system(cmd)
127
+ end
128
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: G4t
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.0'
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - freazesss
@@ -48,6 +48,7 @@ extra_rdoc_files: []
48
48
  files:
49
49
  - bin/g4t
50
50
  - lib/g4t.rb
51
+ - lib/g4tOptions.rb
51
52
  homepage: https://github.com/labsz/g4t
52
53
  licenses:
53
54
  - MIT