cli-framework 0.0.3 → 0.0.4

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/bin/cli +65 -27
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a40fe777fc3aa2fd48d6455036cc52d975e9b33
4
- data.tar.gz: 8dadac809108e04b8e584c3dd4d5b07689d793c0
3
+ metadata.gz: 7fe2f5dbb6cc9de20e476e696875839fda3cd4d2
4
+ data.tar.gz: 90ede149d5293ede3503104e8867a1a1868e858a
5
5
  SHA512:
6
- metadata.gz: 507e2dee17e44497ac64352b517ee20e36abdafcb6394bdedba8bf44076eb50fe8151e4eae6773ccaa9dea75ab388828cd3f64ef54c3d053e4c7db50f10987b2
7
- data.tar.gz: b7e1d9d9c68778959e724bcb9a609b22bfbc7123e2919ffef396a31b92746390fb1840243a532ddea8f559f5acae7cfa4ef75aa6c50febd5234b8c17e4ebbec2
6
+ metadata.gz: cedd52e359d41e7d59f6a00b217b56b020c1d0b45226eb195c1c602aa328daee798151f3c5a311db17975bce27ccd27d4a2a2cd5560f3fc03c1abf788e563923
7
+ data.tar.gz: df99bd15f217fe855525c1976689f1a48fbc60338238a251b533e099e75476226d732a4f2daa29fbe5e4cb1570601dddfa5dfa80073a28a26cbd6c08ce081735
data/bin/cli CHANGED
@@ -4,7 +4,7 @@
4
4
  module CommandLineConfig
5
5
  Name ||= "cli"
6
6
  GemName ||= "cli-framework"
7
- Version ||= "0.0.3"
7
+ Version ||= "0.0.4"
8
8
  Color ||= 'yellow'
9
9
  Else ||= "help"
10
10
  BeforeInit ||= ['check.rb'] #execute scripts before initilatizing the cli
@@ -640,6 +640,14 @@ class CommandLineInterface
640
640
 
641
641
 
642
642
 
643
+ end
644
+
645
+ def Terminal commandString = "", silent: false
646
+ if silent
647
+ `#{commandString}`
648
+ else
649
+ system commandString
650
+ end
643
651
  end
644
652
 
645
653
 
@@ -754,7 +762,34 @@ class CommandAction
754
762
  config[:options] = [] unless config[:options]
755
763
  config[:params] = [] unless config[:params]
756
764
  config[:alias] = "" unless config[:alias]
757
- self.new config
765
+ action = self.new config
766
+
767
+ end
768
+
769
+ def self.description string_desc
770
+ self.register nil unless @@actions.last.class.to_s == self.to_s
771
+ @@actions.last.description = string_desc
772
+ end
773
+
774
+ def self.desc string_desc
775
+ self.register nil unless @@actions.last.class.to_s == self.to_s
776
+ @@actions.last.description = string_desc
777
+ end
778
+
779
+ def self.alias_ string_alias
780
+ @@actions.last.alias = string_alias
781
+ end
782
+
783
+ def self.option optionArray
784
+ @@actions.last.options << optionArray
785
+ end
786
+
787
+ def self.options optionsArray
788
+ @@actions.last.options.push *optionArray
789
+ end
790
+
791
+ def self.params paramsArray
792
+ @@actions.last.args.push *paramsArray
758
793
  end
759
794
 
760
795
  def self.actions
@@ -826,9 +861,10 @@ class String #extend String class in order to add coloration capabilitise
826
861
 
827
862
  end
828
863
 
829
- class ActionAction < CommandLine::Action; register description: "create or overwrite an action",
830
- alias: 'a',
831
- params: ['name']
864
+ class ActionAction < CommandLine::Action; register
865
+ description "create or overwrite an action"
866
+ alias_ 'a'
867
+ params ['name']
832
868
 
833
869
 
834
870
  def action inputs, arguments, options, namespaces
@@ -861,10 +897,10 @@ class ActionAction < CommandLine::Action; register description: "create or over
861
897
  def createAction name,namespaces
862
898
  puts "creating #{name} action"
863
899
  lines = [
864
- "class #{name.capitalize}Action < CommandLine::Action",
865
- " register",
900
+ "class #{name.capitalize}Action < CommandLine::Action; register",
901
+ " ",
866
902
  " def action inputs, arguments, options, namespaces",
867
- " ",
903
+ " # put your code here ;) ",
868
904
  " end",
869
905
  "end",
870
906
  ]
@@ -881,25 +917,23 @@ end
881
917
 
882
918
 
883
919
 
884
- class BuildAction < CommandLine::Action
885
- register description: "build the cli"
920
+ class BuildAction < CommandLine::Action; register
886
921
 
887
-
888
- # description: "this the description of build action"
889
- # params: ["port"]
890
- # options: [['-d -deploy','deploy'], ['-i','international']]
922
+ alias_ "b"
923
+ desc "build & install the cli globaly"
924
+ option ['-s','silent']
925
+ params ['type']
891
926
 
892
927
  def action inputs, arguments, options, namespaces
893
928
  puts "packing the cli .."
894
- CommandLineInterface.terminal "rake install"
929
+ Terminal "rake install", silent: options["silent"]
895
930
  end
896
931
  end
897
932
 
898
933
 
899
934
 
900
935
 
901
- class ErrorAction < CommandLine::Action
902
- register
936
+ class ErrorAction < CommandLine::Action; register
903
937
 
904
938
  def action inputs, arguments, options, namespaces
905
939
  puts "\"#{inputs[0].show if inputs[0]}\" is not a valid #{CommandLineConfig::Name} Command"
@@ -909,8 +943,7 @@ end
909
943
 
910
944
 
911
945
 
912
- class HelpAction < CommandLine::Action
913
- register
946
+ class HelpAction < CommandLine::Action; register
914
947
 
915
948
 
916
949
  def action inputs, arguments, options, namespaces
@@ -965,12 +998,8 @@ class HelpAction < CommandLine::Action
965
998
  end
966
999
  end
967
1000
 
968
- class NewAction < CommandLine::Action
969
- register description: 'create a new cli',
970
- params: ['name', 'color']
971
- # options: [['-g --general', 'general']]
972
-
973
-
1001
+ class NewAction < CommandLine::Action; register
1002
+ description 'create a new cli'
974
1003
 
975
1004
  def action inputs, arguments, options, namespaces
976
1005
  unless arguments['name']
@@ -1008,8 +1037,17 @@ class NewAction < CommandLine::Action
1008
1037
  end
1009
1038
 
1010
1039
 
1011
- class VersionAction < CommandLine::Action
1012
- register description: "return the version on the cli"
1040
+ class UpdateAction < CommandLine::Action; register
1041
+ description "update cli-framework command-line"
1042
+ alias_ 'up'
1043
+
1044
+ def action inputs, arguments, options, namespaces
1045
+ Terminal "gem update cli-framework"
1046
+ end
1047
+ end
1048
+
1049
+
1050
+ class VersionAction < CommandLine::Action; register
1013
1051
 
1014
1052
 
1015
1053
  def action inputs, arguments, options, namespaces
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli-framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilias Bhallil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-26 00:00:00.000000000 Z
11
+ date: 2016-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: terminal-table